Reputation: 21553
I am a bit stuck with how I should implement this in Node.js. Here's the scenario:
In my database, I have bunch of "tasks". These tasks are suppose to do some asynchronous IO. I want to loop through these tasks infinitely and perform them like a queue. When a task is done, it goes back to the queue.
I loop through the database result of all tasks, if the task is already in the queue, i skip, otherwise i add it to the queue.
What's the best way to do this in Node.js?
thanks!
Upvotes: 0
Views: 210
Reputation: 63673
The best way to achieve this is by using Kue. Not only will it help you putting all your tasks in a queue and execute them, but you can also have multiple processes (workers) executing jobs.
Here's a nice tutorial about it: http://nodetuts.com/tutorials/27-kue-jobs.html
Upvotes: 1