Comparing version 0.5.3 to 0.5.4
0.5.4 / 2014-01-09 | ||
================== | ||
* Added start event to jobs. (@clayzermki) | ||
0.5.3 / 2014-01-06 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -27,3 +27,3 @@ var humanInterval = require('human-interval'), | ||
Job.prototype.toJSON=function(){ // create a persistable Mongo object -RR | ||
var self=this, | ||
var self=this, | ||
attrs=self.attrs||{}; | ||
@@ -118,2 +118,4 @@ return { | ||
try { | ||
agenda.emit('start', self); | ||
agenda.emit('start:' + self.attrs.name, self); | ||
if(definition.fn.length == 2) { | ||
@@ -120,0 +122,0 @@ definition.fn(self, jobCallback); |
{ | ||
"name": "agenda", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Light weight job scheduler for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Agenda | ||
[![Build Status](https://api.travis-ci.org/rschmukler/agenda.png)](http://travis-ci.org/rschmukler/agenda) | ||
[![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/rschmukler/agenda.png)](https://codeclimate.com/github/rschmukler/agenda/badges) | ||
[![Build Status](https://api.travis-ci.org/rschmukler/agenda.png)](http://travis-ci.org/rschmukler/agenda) | ||
[![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/rschmukler/agenda.png)](https://codeclimate.com/github/rschmukler/agenda/badges) | ||
[![Coverage Status](https://coveralls.io/repos/rschmukler/agenda/badge.png)](https://coveralls.io/r/rschmukler/agenda) | ||
Agenda is a light-weight job scheduling library for Node.js. | ||
Agenda is a light-weight job scheduling library for Node.js. | ||
@@ -43,3 +43,3 @@ It offers: | ||
var data = job.attrs.data; | ||
emailClient.send({ | ||
emailClient.send({ | ||
to: data.to, | ||
@@ -77,3 +77,3 @@ from: 'example@example.com', | ||
## Configuring an agenda | ||
## Configuring an agenda | ||
All configuration methods are chainable, meaning you can do something like: | ||
@@ -250,3 +250,3 @@ | ||
Schedules a job to run `name` once immediately. | ||
Schedules a job to run `name` once immediately. | ||
@@ -260,2 +260,6 @@ `data` is an optional argument that will be passed to the processing function | ||
```js | ||
agenda.now('do the hokey pokey'); | ||
``` | ||
Returns an instance of a `jobName` with `data`. This does *NOT* save the job in | ||
@@ -301,7 +305,7 @@ the database. See below to learn how to manually work with jobs. | ||
This will ensure that no other job processor (this one included) attempts to run the job again | ||
This will ensure that no other job processor (this one included) attempts to run the job again | ||
for the next 10 seconds. If you have a particularly long running job, you will want to | ||
specify a longer lockLifetime. | ||
specify a longer lockLifetime. | ||
By default it is 10 minutes. Typically you shouldn't have a job that runs for 10 minutes, | ||
By default it is 10 minutes. Typically you shouldn't have a job that runs for 10 minutes, | ||
so this is really insurance should the job queue crash before the job is unlocked. | ||
@@ -385,2 +389,11 @@ | ||
- `start` - called just before a job starts | ||
- `start:job name` - called just before the specified job starts | ||
```js | ||
agenda.on('start', function(job) { | ||
console.log("Job %s starting", job.attrs.name); | ||
}); | ||
``` | ||
- `complete` - called when a job finishes, regardless of if it succeeds or fails | ||
@@ -420,7 +433,7 @@ - `complete:job name` - called when a job finishes, regardless of if it succeeds or fails | ||
guarantee the same level of persistence as Mongo (should the server need to be | ||
restarted/crash). | ||
restarted/crash). | ||
Agenda decides to focus on persistence without requiring special configuration | ||
of Redis (thereby degrading the performance of the Redis server on non-critical | ||
data, such as sessions). | ||
data, such as sessions). | ||
@@ -427,0 +440,0 @@ Ultimately if enough people want a Redis driver instead of Mongo, I will write |
@@ -365,2 +365,18 @@ var mongoCfg = 'localhost:27017/agenda-test', | ||
describe('events', function() { | ||
it('emits start event', function(done) { | ||
var job = new Job({agenda: jobs, name: 'jobQueueTest'}); | ||
jobs.once('start', function(j) { | ||
expect(j).to.be(job); | ||
done(); | ||
}); | ||
job.run(); | ||
}); | ||
it('emits start:job name event', function(done) { | ||
var job = new Job({agenda: jobs, name: 'jobQueueTest'}); | ||
jobs.once('start:jobQueueTest', function(j) { | ||
expect(j).to.be(job); | ||
done(); | ||
}); | ||
job.run(); | ||
}); | ||
it('emits complete event', function(done) { | ||
@@ -407,3 +423,3 @@ var job = new Job({agenda: jobs, name: 'jobQueueTest'}); | ||
}); | ||
it('emits error:job name event', function(done) { | ||
it('emits fail:job name event', function(done) { | ||
var job = new Job({agenda: jobs, name: 'failBoat'}); | ||
@@ -410,0 +426,0 @@ jobs.once('fail:failBoat', function(err, j) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39586
775
461