0

I read rack middleware is for modifying the current request/response, but what about having a SendEmail middlewares which would look at env['user_id'] to send emails.

Let's assume the entire process (request + sending emails) will be async.

sent-hil
  • 18,635
  • 16
  • 56
  • 74
  • Well, I've a Goliath app, where one endpoint was growing very complex. Its hard to test and maintain so I decided to cut it up. Original plan was to have many endpoints and communicate between them via http, but was unable to do that. This was the second idea. Another idea is to use EventMachine queues, i.e. put the `user_id` into `SendEmail` queue and work that elsewhere. Mostly concerned with easy maintenance and testing at this point. – sent-hil May 10 '12 at 14:37
  • Adding the job to a queue is definitely a better option. – Andrew Marshall May 10 '12 at 15:00
  • I think I tested Goliath wrong, so http idea is possible, is hitting '/send_email' via http a better option? I don't see very much info about EM Queues on the web aside from trivial examples, so not sure about them. – sent-hil May 10 '12 at 15:42
  • @sent-hil, pretty sure Andrew is talking about Resque or delayed_job queues (I certainly am) ;) – d11wtq May 10 '12 at 23:57

1 Answers1

1

If you really want to do it in Goliath I'd suggest creating a plugin and doing it in there. Create a queue in the config and have the plugin pop items from the queue and send the mail.

dj2
  • 9,534
  • 4
  • 29
  • 52