bodacious
v0.6.0
Published
Job manager with multiple store support, based on Bull
Downloads
12
Readme
Bodacious
Persistently add, pause, resume tasks on your server without the fear of loosing your memory data from a crash. Originally conceived as an upgrade of Bull to support multiple stores.
Features
- Multi-store support
- Serial or parallel execution
- Auto-run when new jobs arrive
...
Install
Using npm
npm install bodacious
Usage
var Queue = require('bodacious');
var queue = Queue('my_queue'); // name should not have spaces...
queue.process(function(job, done){
// execute asynchronously and report progress
job.progress(42);
// call done when finished
done();
// or give a error if error
done(Error('there was an error'));
// or pass it a result
done(null, { ...[response]... });
// If the job throws an unhandled exception it is also handled correctly
throw (Error('some unexpected error'));
});
queue.add({ ...[data]... });
A queue can be paused and resumed:
queue.pause(function(){
// queue is paused now
});
queue.resume(function(){
// queue is resumed now
});
A queue emits also some useful events:
.on('ready', function() {
// Queue ready for job
})
.on('error', function(error) {
// Error
})
.on('active', function(job){
// Job started
})
.on('progress', function(job, progress){
// Job progress updated!
})
.on('completed', function(job, result){
// Job completed with output result!
})
.on('failed', function(job, err){
// Job failed with reason err!
})
.on('paused', function(){
// The queue has been paused
})
.on('resumed', function(job){
// The queue has been resumed
})
.on('cleaned', function(jobs, type) {
//jobs is an array of cleaned jobs
//type is the type of job cleaned
//see clean for details
});
Credits
Initiated by Makis Tracend ( @tracend )
Distributed through Makesites.org
Thanks
Originally based on Bull by OptimalBits
License
Released under the MIT license