A backend-agnostic job queue.
The general direction I'm going for is expressed in these code snippets. Some of this is implemented while other parts are not.
var widgetQueue = require('quench')({backend: 'redis', name: 'widgets'});
var shippingQueue = require('quench')({backend: 'redis', name: 'shipping'});
widgetQueue.add('my first widget', {
color: 'red',
size: 'large'
}, function(err, res) {});
// Create a second one, and so on ...
widgetQueue.add('a widget for bob', {
color: 'purple',
size: 'medium'
}, function(err, res) {});
widgetQueue.take(function(err, job) {
// Do some work ...
// Update progress
job.progress(100);
// We're done!
job.done();
});
widgetQueue.take(function(err, job) {
// Do some work ...
// Update progress
job.progress(15);
// I've done all I can, pass it to someone else
job.pass(shippingQueue, function(err, res) {});
});
shippingQueue.take(function(err, job) {
// Do some work ...
// Uh-oh, the delivery failed
job.fail(Error("Your widget couldn\'t be delivered"));
});