delayed-job is a horizontally scalable Node.js implementation of Ruby's delayed_job. Using semaphore locks it aims to provide an atomic interface to a federation of workers operating on the same job queue. Initial work has focussed on a Redis backed database, however more backend implementations are possible.
npm install delayed-job
var Scheduler = require('delayed-job');
var schedule = Scheduler.createSchedule({
backend: {
name: 'redis',
jobHoldingBay: 'myUniqueListKey'
}
});
schedule.on('job',function(job) {
console.log('Received job',job);
});
var myJob = {
title: 'Great Gig In The Sky'
};
schedule.delay(myJob,2000);
Schedule a job for execution
- errors thrown will result in re-establishing the scheduler [expand]
- Single atomic source of truth
- Db interactions are also atomic
- Jobs emitted have no immediate relationship to one another