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

agenda-batch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agenda-batch

A batch process for the agenda module

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

batch-agenda

A batching tool for the agenda.js tool that will proxy data to a task that has not been run.

Initialize the library:

var Agenda = require('agenda');
var Batch = require('batch');

var agenda = new Agenda({ db: { address: 'db-connection:24717' } });
batch = new Batch( agenda );

Define jobs using the agenda module:

agenda.define('email-some-users', function(err, cb) {
  // Do Something
});

Batch a process by calling the batch function.

batch.batch('batch-key', { data }, 'in 40 minutes', 'email-some-users');

Subsequent calls to the batch function will add data to the original waiting job. Important note. The timing of existing jobs will not be reset. The purpose of the function is to be able to send additional data to jobs in the queue without having to care when they will fire.

batch.batch('batch-key', { MORE-data }, 'in 40 minutes', 'job-name');

In the callback, the data will be found in the attrs.data.jobData attribute.

batch.define('job-name', function(job) {
  job.attrs.data.jobData // Will be an array of the data that was 'batched'.
  job.attrs.data.key // The key used to store this batch for this job.
});

Once the job is complete, the key will be abandoned and the job removed for the next job to use (on subsequent calls to batch());

Take a look at lib/cli, or run it via npm run cli to see an example. Requires a mongo instance for agenda to run.

FAQs

Package last updated on 19 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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