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

agenda

Package Overview
Dependencies
Maintainers
5
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.10.1 to 0.10.2

51

History.md

@@ -1,50 +0,7 @@

Next 2.0.0
==========
Next
=======
* Drop support for MongoDB 2.4 ([#497](https://github.com/agenda/agenda/pull/497))
* Replace the deprecated `findAndModify` method from native MongoDB driver to `findOneAndUpdate` (#448)
* Going forward, we won't ensure Node.js v0.10 and v0.11 compatibility anymore (#449)
Next 1.0.0 / 2017-08-?
======================
* Gracefully recover from losing connection to MongoDB ([#472](https://github.com/agenda/agenda/pull/472))
BREAKING
--------
* Fix jobs not running in order of them being queued ([#464](https://github.com/agenda/agenda/pull/464))
* Changes in Cron string parsing, changed parsing library from [ncb000gt/node-cron](https://www.npmjs.com/package/cron) to [harrisiirak/cron-parser](https://www.npmjs.com/package/cron-parser) ([#475](https://github.com/agenda/agenda/pull/475))
Previously Agenda would treat months as 0-11 where as normally, cron months are parsed as 1-12.
```
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 0-11) NOTE: Difference here
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
```
Starting in version `1.0.0`, cron will be parsed in the standard UNIX style:
```
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12) NOTE: Difference here
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
```
0.10.0 / 2017-08-08
==================
* Replace the deprecated `findAndModify` method from native MongoDB driver to `findOneAndUpdate` ([#448](https://github.com/agenda/agenda/pull/448))
* Going forward, we won't ensure Node.js v0.10 and v0.11 compatibility anymore ([#449](https://github.com/agenda/agenda/pull/449))
* Code cleanup ([#491](https://github.com/agenda/agenda/pull/491), [#489](https://github.com/agenda/agenda/pull/489), [#488](https://github.com/agenda/agenda/pull/488), [#487](https://github.com/agenda/agenda/pull/487))
0.9.1 / 2017-03-22

@@ -51,0 +8,0 @@ ==================

70

lib/agenda.js

@@ -41,4 +41,2 @@ /**

this._defaultLockLifetime = config.defaultLockLifetime || 10 * 60 * 1000; // 10 minute default lockLifetime
this._sort = config.sort || { nextRunAt: 1, priority: -1 };
this._indices = Object.assign({ name : 1 }, this._sort, { priority: -1, lockedAt: 1, nextRunAt: 1, disabled: 1 });

@@ -90,3 +88,3 @@ this._isLockingOnTheFly = false;

collection = collection || 'agendaJobs';
options = Object.assign({autoReconnect: true, reconnectTries: Number.MAX_SAFE_INTEGER, reconnectInterval: this._processEvery}, options);
options = options || {};
var self = this;

@@ -122,14 +120,16 @@

debug('attempting index creation');
this._collection.createIndex(
this._indices,
{ name: 'findAndLockNextJobIndex' },
function(err, result) {
if (err) {
debug('index creation failed, attempting legacy index creation next');
} else {
debug('index creation success');
}
handleLegacyCreateIndex(err, result, self, cb)
this._collection.createIndexes([{
"key": {"name" : 1, "priority" : -1, "lockedAt" : 1, "nextRunAt" : 1, "disabled" : 1},
"name": "findAndLockNextJobIndex1"
}, {
"key": {"name" : 1, "lockedAt" : 1, "priority" : -1, "nextRunAt" : 1, "disabled" : 1},
"name": "findAndLockNextJobIndex2"
}], function(err, result) {
if (err) {
debug('index creation failed, attempting legacy index creation next');
} else {
debug('index creation success');
}
);
handleLegacyCreateIndex(err, result, self, cb)
});
};

@@ -146,3 +146,3 @@

function handleLegacyCreateIndex(err, result, self, cb) {
if (err && err.message !== 'no such cmd: createIndex') {
if (err && err.message !== 'no such cmd: createIndexes') {
debug('not attempting legacy index, emitting error');

@@ -154,5 +154,9 @@ self.emit('error', err);

self._collection.ensureIndex(
self._indices,
{ name: 'findAndLockNextJobIndex' }
{"name": 1, "priority": -1, "lockedAt": 1, "nextRunAt": 1, "disabled": 1},
{name: "findAndLockNextJobIndex1"}
);
self._collection.ensureIndex(
{"name": 1, "lockedAt": 1, "priority": -1, "nextRunAt": 1, "disabled": 1},
{name: "findAndLockNextJobIndex2"}
);
self.emit('ready');

@@ -245,14 +249,2 @@ }

/**
* Set the sort query for finding next job
* Default is { nextRunAt: 1, priority: -1 }
* @param {Object} query sort query object for MongoDB
* @returns {exports} agenda instance
*/
Agenda.prototype.sort = function(query) {
debug('Agenda.sort([Object])');
this._sort = query;
return this;
}
/**
* Given a name and some data, create a new job

@@ -689,14 +681,8 @@ * @param {String} name name of job

// Don't try and access MongoDB if we've lost connection to it.
// Trying to resolve crash on Dev PC when it resumes from sleep. NOTE: Does this still happen?
var s = this._mdb.s || this._mdb.db.s;
if (s.topology.connections().length === 0) {
if (s.topology.autoReconnect && !s.topology.isDestroyed()) {
// continue processing but notify that Agenda has lost the connection
debug('Missing MongoDB connection, not attempting to find and lock a job');
self.emit('error', new Error('Lost MongoDB connection'));
cb();
} else {
// no longer recoverable
debug('topology.autoReconnect: %s, topology.isDestroyed(): %s', s.topology.autoReconnect, s.topology.isDestroyed());
cb(new Error('MongoDB connection is not recoverable, application restart required'));
}
debug('missing MongoDB connection, not attempting to find and lock a job');
cb(new Error('No MongoDB Connection'));
} else {

@@ -733,5 +719,5 @@ /**

* Query used to affect what gets returned
* @type {{returnOriginal: boolean, sort: object}}
* @type {{returnOriginal: boolean, priority: number}}
*/
var JOB_RETURN_QUERY = {returnOriginal: false, sort: this._sort };
var JOB_RETURN_QUERY = {returnOriginal: false, priority: -1};

@@ -1092,2 +1078,2 @@ // Find ONE and ONLY ONE job and set the 'lockedAt' time so that job begins to be processed

}
}
}
{
"name": "agenda",
"version": "0.10.1",
"version": "0.10.2",
"description": "Light weight job scheduler for Node.js",

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

@@ -1,27 +0,11 @@

<p align="center">
<img src="https://cdn.rawgit.com/agenda/agenda/master/agenda.svg" alt="Agenda" width="100" height="100">
</p>
<p align="center">
A light-weight job scheduling library for Node.js
</p>
<p align="center">
<a href="http://travis-ci.org/agenda/agenda">
<img src="https://api.travis-ci.org/agenda/agenda.svg" alt="Build Status">
</a>
<a href="https://david-dm.org/agenda/agenda">
<img src="https://david-dm.org/agenda/agenda/status.svg" alt="dependencies Status">
</a>
<a href="https://david-dm.org/agenda/agenda?type=dev">
<img src="https://david-dm.org/agenda/agenda/dev-status.svg" alt="devDependencies Status">
</a>
<a href="https://coveralls.io/github/agenda/agenda?branch=master">
<img src="https://coveralls.io/repos/github/agenda/agenda/badge.svg?branch=master" alt="Coverage Status">
</a>
<br>
<br>
<br>
</p>
# Agenda
[![Build Status](https://api.travis-ci.org/agenda/agenda.svg)](http://travis-ci.org/agenda/agenda)
[![dependencies Status](https://david-dm.org/agenda/agenda/status.svg)](https://david-dm.org/agenda/agenda)
[![devDependencies Status](https://david-dm.org/agenda/agenda/dev-status.svg)](https://david-dm.org/agenda/agenda?type=dev)
[![Coverage Status](https://coveralls.io/repos/github/agenda/agenda/badge.svg?branch=master)](https://coveralls.io/github/agenda/agenda?branch=master)
# Agenda offers
Agenda is a light-weight job scheduling library for Node.js.
It offers:
- Minimal overhead. Agenda aims to keep its code base small.

@@ -43,3 +27,2 @@ - Mongo backed persistence layer.

# Example Usage

@@ -57,3 +40,3 @@

// or pass additional connection options:
// var agenda = new Agenda({db: {address: mongoConnectionString, collection: 'jobCollectionName', options: {ssl: true}}});
// var agenda = new Agenda({db: {address: mongoConnectionString, collection: 'jobCollectionName', options: {server:{auto_reconnect:true}}}});

@@ -313,8 +296,2 @@ // or pass in an existing mongodb-native MongoClient instance

### sort(query)
Takes a `query` which specifies the sort query to be used for finding and locking the next job.
By default it is `{ nextRunAt: 1, priority: -1 }`, which obeys a first in first out approach, with respect to priority.
## Agenda Events

@@ -761,11 +738,2 @@

### What is the order in which jobs run?
Jobs are run with priority in a first in first out order (so they will be run in the order they were scheduled AND with respect to highest priority).
For example, if we have two jobs named "send-email" queued (both with the same priority), and the first job is queued at 3:00 PM and second job is queued at 3:05 PM with the same `priority` value, then the first job will run first if we start to send "send-email" jobs at 3:10 PM. However if the first job has a priority of `5` and the second job has a priority of `10`, then the second will run first (priority takes precedence) at 3:10 PM.
The default [MongoDB sort object](https://docs.mongodb.com/manual/reference/method/cursor.sort/) is `{ nextRunAt: 1, priority: -1 }` and can be changed through the option `sort` when configuring Agenda.
### Sample Project Structure?

@@ -865,13 +833,2 @@

### Recovering lost Mongo connections ("auto_reconnect")
Agenda is configured by default to automatically reconnect indefinitely, emitting an [error event](#agenda-events)
when no connection is available on each [process tick](#processeveryinterval), allowing you to restore the Mongo
instance without having to restart the application.
However, if you are using an [existing Mongo client](#mongomongoclientinstance)
you'll need to configure the `reconnectTries` and `reconnectInterval` [connection settings](http://mongodb.github.io/node-mongodb-native/2.2/reference/connecting/connection-settings/)
manually, otherwise you'll find that Agenda will throw an error with the message "MongoDB connection is not recoverable,
application restart required" if the connection cannot be recovered within 30 seconds.
# Example Project Structure

@@ -1007,3 +964,3 @@

* * * * * *
| | | | | |
| | | | | |
| | | | | +-- Year (range: 1900-3000)

@@ -1020,3 +977,3 @@ | | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)

* * * * * *
| | | | | |
| | | | | |
| | | | | +-- Year (range: 1900-3000)

@@ -1064,3 +1021,2 @@ | | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)

- [@jakeorr](http://github.com/jakeorr)
- [@niftylettuce](http://github.com/niftylettuce)

@@ -1067,0 +1023,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