I've updated the code to use BLPOP as Thomas suggested.
I've also created an npm package for it.
Lingering concerns:
1. How can I be sure that a task wont crash the worker process if it
produces an exception?
1. Try/catch works if the task is synchronous, what if it does some
aync stuff?
2. If a task does async stuff, then a single worker could be working on
any number of tasks all at once? I want to limit this.
1. I could increment a counter in the TaskWorker.handleTask function,
then decrement it in the done callback that is passed, of course this
would
force the task implementors to always be sure that they call done() when
their task completes.
On Friday, 12 April 2013 17:34:09 UTC-4, Tom Dunn wrote:
>
> Hello all!
>
> I am somewhat new here, but have been using nodejs and javascript in
> general for some time now. I needed a way to distribute task created by an
> initiator to some number of workers.
>
> This is a quick prototype that I hacked together yesterday. If anyone has
> any feedback to give, I would greatly appreciate it. Specifically I am
> looking for feedback regarding my design, and whether or not there is
> interest in this.
>
> Thanks!
> Tom
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.