How should I do this in Node.js
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?
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