Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

agenda

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agenda - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

6

History.md
0.4.4 / 2013-12-13
==================
* fix job.toJson method: add failReason & failedAt attrs (Broken in 0.4.3 and 0.4.2)
* fix job cb for working with 'q' promises
0.4.3 / 2013-12-13

@@ -3,0 +9,0 @@ ==================

43

lib/job.js

@@ -38,3 +38,5 @@ var humanInterval = require('human-interval'),

repeatInterval:attrs.repeatInterval,
type: attrs.type
type: attrs.type,
failReason: attrs.failReason,
failedAt: attrs.failedAt
};

@@ -97,5 +99,21 @@ };

self.computeNextRunAt();
try {
var jobFinishedSuccessfully = function(err) {
if(err) throw err;
var jobFinishedFailed = function(e){
now = new Date();
self.fail(e.message);
agenda._runningJobs--;
agenda.emit('fail', e, self);
agenda.emit('fail:' + self.attrs.name, e, self);
definition.running--;
self.attrs.lastFinishedAt = now;
self.save(function(err, job) {
if(cb)
cb(e, job);
});
};
var jobFinishedSuccessfully = function(err) {
if(err) {
jobFinishedFailed(err);
}else{
now = new Date();

@@ -108,3 +126,6 @@ agenda._runningJobs--;

agenda.emit('success:' + self.attrs.name, self);
};
}
};
try {
if(definition.fn.length == 2) {

@@ -117,13 +138,3 @@ definition.fn(self, jobFinishedSuccessfully);

} catch(e) {
now = new Date();
self.fail(e.message);
agenda._runningJobs--;
agenda.emit('fail', e, self);
agenda.emit('fail:' + self.attrs.name, e, self);
definition.running--;
self.attrs.lastFinishedAt = now;
self.save(function(err, job) {
if(cb)
cb(e, job);
});
jobFinishedFailed(e);
} finally {

@@ -130,0 +141,0 @@ agenda.emit('complete', self);

{
"name": "agenda",
"version": "0.4.3",
"version": "0.4.4",
"description": "Light weight job scheduler for Node.js",

@@ -41,4 +41,5 @@ "main": "index.js",

"coveralls": "~2.3.0",
"blanket": "~1.1.5"
"blanket": "~1.1.5",
"q": "*"
}
}

@@ -1,11 +0,12 @@

var expect = require('expect.js'),
mongo = require('mongoskin').db('localhost:27017/agenda-test', {w: 0}),
var mongoCfg = 'localhost:27017/agenda-test',
expect = require('expect.js'),
mongo = require('mongoskin').db(mongoCfg, {w: 0}),
jobs = require('../index.js')({
defaultConcurrency: 5,
db: {
address: 'localhost:27017/agenda-test'
address: mongoCfg
}
}),
Job = require('../lib/job.js');
before(function(done) {

@@ -23,11 +24,11 @@ mongo.collection('agendaJobs').remove({}, done);

it('sets the database', function() {
jobs.database('localhost:27017/agenda-test');
jobs.database(mongoCfg);
expect(jobs._db.skinDb._dbconn.databaseName).to.be('agenda-test');
});
it('sets the collection', function() {
jobs.database('localhost:27017/agenda-test', 'myJobs');
jobs.database(mongoCfg, 'myJobs');
expect(jobs._db.collectionName).to.be('myJobs');
});
it('returns itself', function() {
expect(jobs.database('localhost:27017/agenda-test')).to.be(jobs);
expect(jobs.database(mongoCfg)).to.be(jobs);
});

@@ -300,2 +301,15 @@ });

});
it('handles errors with q promises', function(done) {
job.attrs.name = 'failBoat2';
jobs.define('failBoat2', function(job, cb) {
var Q = require('q');
Q.delay(100).then(function(){
throw(new Error("Zomg fail"));
}).fail(cb).done();
});
job.run(function(err) {
expect(err).to.be.ok();
done();
});
});
});

@@ -302,0 +316,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc