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.4 to 0.5.5

5

History.md
0.5.5 / 2014-01-28
==================
* added support to directly give mongoskin object, to help minimize connections
0.5.4 / 2014-01-09

@@ -3,0 +8,0 @@ ==================

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

this.database(config.db.address, config.db.collection);
else if(config.mongo)
this._db = config.mongo;
};

@@ -24,2 +26,6 @@

Agenda.prototype.mongo = function(db) {
this._db = db;
};
Agenda.prototype.database = function(url, collection) {

@@ -26,0 +32,0 @@ collection = collection || 'agendaJobs';

2

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

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

@@ -22,2 +22,4 @@ # Agenda

You will also need a working [mongo](http://www.mongodb.org/) database to point it to.
# Example Usage

@@ -88,2 +90,3 @@

### database(url, [collectionName])

@@ -104,2 +107,14 @@

### mongo(mongoSkinInstance)
Use an existing mongoskin instance. This can help consolidate connections to a
database. You can instead use `.database` to have agenda handle connecting for
you.
You can also specify it during instantiation.
```js
var agenda = new Agenda({mongo: mongoSkinInstance});
```
### processEvery(interval)

@@ -258,4 +273,2 @@

### create(jobName, data)
```js

@@ -265,2 +278,4 @@ agenda.now('do the hokey pokey');

### create(jobName, data)
Returns an instance of a `jobName` with `data`. This does *NOT* save the job in

@@ -442,5 +457,66 @@ the database. See below to learn how to manually work with jobs.

### Spawning / forking processes.
Ultimately Agenda can work from a single job queue across multiple machines, node processes, or forks. If you are interested in having more than one worker, [Bars3s](http://github.com/bars3s) has written up a fantastic example of how one might do it:
```js
var cluster = require('cluster'),
cpuCount = require('os').cpus().length,
jobWorkers = [],
webWorkers = [];
if (cluster.isMaster) {
// Create a worker for each CPU
for (var i = 0; i < cpuCount; i += 1) {
addJobWorker();
addWebWorker();
}
cluster.on('exit', function (worker, code, signal) {
if (jobWorkers.indexOf(worker.id) != -1) {
console.log('job worker ' + worker.process.pid + ' died. Trying to respawn...');
removeJobWorker(worker.id);
addJobWorker();
}
if (webWorkers.indexOf(worker.id) != -1) {
console.log('http worker ' + worker.process.pid + ' died. Trying to respawn...');
removeWebWorker(worker.id);
addWebWorker();
}
});
} else {
if (process.env.web) {
console.log('start http server: ' + cluster.worker.id);
require('./app/web-http');//initialize the http server here
}
if (process.env.job) {
console.log('start job server: ' + cluster.worker.id);
require('./app/job-worker');//initialize the agenda here
}
}
function addWebWorker() {
webWorkers.push(cluster.fork({web: 1}).id);
}
function addJobWorker() {
webWorkers.push(cluster.fork({job: 1}).id);
}
function removeWebWorker(id) {
webWorkers.splice(webWorkers.indexOf(id), 1);
}
function removeJobWorker(id) {
jobWorkers.splice(jobWorkers.indexOf(id), 1);
}
```
# License

@@ -447,0 +523,0 @@ (The MIT License)

var mongoCfg = 'localhost:27017/agenda-test',
expect = require('expect.js'),
mongo = require('mongoskin').db(mongoCfg, {w: 0}),
jobs = require('../index.js')({
Agenda = require('../index.js'),
jobs = new Agenda({
defaultConcurrency: 5,

@@ -35,2 +36,10 @@ db: {

});
describe('mongo', function() {
it('sets the _db directly', function() {
var agenda = new Agenda();
agenda.mongo({hello: 'world'});
expect(agenda._db).to.have.property('hello', 'world');
});
});
describe('processEvery', function() {

@@ -37,0 +46,0 @@ it('sets the processEvery time', function() {

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