agenda
Advanced tools
Comparing version 0.7.0 to 0.7.2
@@ -0,2 +1,7 @@ | ||
0.7.2 / 2015-10-22 | ||
================== | ||
* Rollback job completion callback to pre-0.7.0 | ||
* Emit events when Agenda init is ready or has failed | ||
0.7.0 / 2015-09-29 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -40,3 +40,9 @@ /* Code forked from https://github.com/rschmukler/agenda | ||
if (config.db) { | ||
var self = this; | ||
this.database(config.db.address, config.db.collection, config.db.options, function(err, coll) { | ||
if (err) { | ||
self.emit('error', err); | ||
} else { | ||
self.emit('ready'); | ||
} | ||
if (cb) { | ||
@@ -43,0 +49,0 @@ cb(err, coll); |
@@ -1,5 +0,5 @@ | ||
/** @package | ||
/** @package | ||
job.js | ||
21/04/2015 NF Removed database code. ie. From Job.remove() | ||
@@ -181,16 +181,7 @@ | ||
self.attrs.lockedAt = null; | ||
if (self.attrs.nextRunAt) { | ||
self.save(postCommit); | ||
} else { | ||
self.remove(function(removeErr) { | ||
postCommit(removeErr, self); | ||
}); | ||
} | ||
function postCommit(commitErr, job) { | ||
cb && cb(err || commitErr, job); | ||
self.save(function(saveErr, job) { | ||
cb && cb(err || saveErr, job); | ||
agenda.emit('complete', self); | ||
agenda.emit('complete:' + self.attrs.name, self); | ||
} | ||
}); | ||
}; | ||
@@ -197,0 +188,0 @@ |
{ | ||
"name": "agenda", | ||
"version": "0.7.0", | ||
"version": "0.7.2", | ||
"description": "Light weight job scheduler for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,9 +49,11 @@ # Agenda | ||
agenda.every('3 minutes', 'delete old users'); | ||
agenda.on('ready', function() { | ||
agenda.every('3 minutes', 'delete old users'); | ||
// Alternatively, you could also do: | ||
agenda.every('*/3 * * * *', 'delete old users'); | ||
// Alternatively, you could also do: | ||
agenda.every('*/3 * * * *', 'delete old users'); | ||
agenda.start(); | ||
}); | ||
agenda.start(); | ||
``` | ||
@@ -70,10 +72,14 @@ | ||
agenda.schedule('in 20 minutes', 'send email report', {to: 'admin@example.com'}); | ||
agenda.start(); | ||
agenda.on('ready', function() { | ||
agenda.schedule('in 20 minutes', 'send email report', {to: 'admin@example.com'}); | ||
agenda.start(); | ||
}); | ||
``` | ||
```js | ||
var weeklyReport = agenda.create('send email report', {to: 'another-guy@example.com'}) | ||
weeklyReport.repeatEvery('1 week').save(); | ||
agenda.start(); | ||
agenda.on('ready', function() { | ||
var weeklyReport = agenda.create('send email report', {to: 'another-guy@example.com'}) | ||
weeklyReport.repeatEvery('1 week').save(); | ||
agenda.start(); | ||
}); | ||
``` | ||
@@ -88,2 +94,3 @@ | ||
- [Configuring an agenda](#configuring-an-agenda) | ||
- [Agenda Events](#agenda-events) | ||
- [Defining job processors](#defining-job-processors) | ||
@@ -140,2 +147,4 @@ - [Creating jobs](#creating-jobs) | ||
Agenda will emit a `ready` event (see [Agenda Events](#agenda-events)) when properly connected to the database and it is safe to start using Agenda. | ||
### mongo(mongoClientInstance) | ||
@@ -260,2 +269,15 @@ | ||
## Agenda Events | ||
An instance of an agenda will emit the following events: | ||
- `ready` - called when Agenda mongo connection is successfully opened | ||
- `error` - called when Agenda mongo connection process has thrown an error | ||
```js | ||
agenda.on('ready', function() { | ||
agenda.start(); | ||
}); | ||
``` | ||
## Defining Job Processors | ||
@@ -262,0 +284,0 @@ |
92638
908
1725