wereHamster/mojo — pull request #6 by kof (2013-04-18 09:02:14+00:00)
Title: use error events instead of throwing, order templates by FIFO, make rotation optional

Hi, we are using mojo in production. We had an issue which we couldn't understand for a long time. Sometimes tasks were not processed and they timed out. After a deep investigation I found out, the reason. Mojo is doing the template rotation, which is ok if one has lots of tasks of one type so tasks of a second type need to wait too long. The downside of this approach is if you have lets say 10 different templates and we do polling every 1 second, we will come to process the 10. template in 10 seconds which is a way too long. Under load we have lots of tasks, due to this timeout our worker where not fast enough to complete them and they timed out.

We are using this version in production since 2 weeks and it seems to be fine.

Changes:

- I have changed the default template rotation behaviour to FIFO, rotaion can still be done optionally.
- Errors will be emited now, hot thrown ... it is a bad idea to throw errors in node, because they land in uncaughtException handler and this errors have an empty stack currently.

Cheers,
Oleg