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.5.5 to 0.5.6

6

History.md
0.5.6 / 2014-02-18
==================
* Added failing for jobs with undefined definitions
* Added agenda.purge() to remove old jobs
0.5.5 / 2014-01-28

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

@@ -67,2 +67,7 @@ var Job = require('./job.js'),

Agenda.prototype.purge = function(cb) {
var definedNames = Object.keys(this._definitions);
this._db.remove({name: {$not: {$in: definedNames}}}, cb);
};
Agenda.prototype.define = function(name, options, processor) {

@@ -69,0 +74,0 @@ if(!processor) {

1

lib/job.js

@@ -119,2 +119,3 @@ var humanInterval = require('human-interval'),

agenda.emit('start:' + self.attrs.name, self);
if(!definition) throw new Error('Undefined job');
if(definition.fn.length == 2) {

@@ -121,0 +122,0 @@ definition.fn(self, jobCallback);

2

package.json
{
"name": "agenda",
"version": "0.5.5",
"version": "0.5.6",
"description": "Light weight job scheduler for Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -72,2 +72,3 @@ # Agenda

- [Creating jobs](#creating-jobs)
- [Managing jobs](#managing-jobs)
- [Starting the job processor](#starting-the-job-processor)

@@ -287,2 +288,27 @@ - [Multiple job processors](#multiple-job-processors)

## Managing Jobs
### jobs(mongoskin query)
Lets you query all of the jobs in the agenda job's database. This is a full [mongoskin](https://github.com/kissjs/node-mongoskin)
`find` query. See mongoskin's documentation for details.
```js
agenda.jobs({name: 'printAnalyticsReport'}, function(err, jobs) {
// Work with jobs (see below)
});
```
### purge(cb)
Removes all jobs in the database without defined behaviors. Useful if you change a definition name and want to remove old jobs.
*IMPORTANT:* Do not run this before you finish defining all of your jobs. If you do, you will nuke your database of jobs.
```js
agenda.purge(function(err, numRemoved) {
});
```
## Starting the job processor

@@ -289,0 +315,0 @@

@@ -168,2 +168,19 @@ var mongoCfg = 'localhost:27017/agenda-test',

describe('purge', function() {
it('removes all jobs without definitions', function(done) {
var job = jobs.create('no definition');
job.save(function() {
jobs.jobs({name: 'no definition'}, function(err, j) {
expect(j).to.have.length(1);
jobs.purge(function() {
jobs.jobs({name: 'no definition'}, function(err, j) {
expect(j).to.have.length(0);
done();
});
});
});
});
});
});
describe('saveJob', function() {

@@ -291,2 +308,11 @@ it('persists job to the database', function(done) {

});
it('fails if job is undefined', function(done) {
job = new Job({agenda: jobs, name: 'not defined'});
job.run(function() {
expect(job.attrs.failedAt).to.be.ok();
expect(job.attrs.failReason).to.be('Undefined job');
done();
});
});
it('updates nextRunAt', function(done) {

@@ -293,0 +319,0 @@ var now = new Date();

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