0.0.1 • Published 9 years ago

adrian v0.0.1

Weekly downloads
4
License
BSD
Repository
github
Last release
9 years ago

Adrian

Robust and thorough job queue on top of MongoDB, featuring retries and timeouts.

Usage

var Queue = require('adrian');

var queue = new Queue('collection-name');

// Create job
var job = { some: 'data' };

// Enqueue job (and get a ticket ID)
queue.createJob(job, function(err, document) {
  // Job is in the queue.
  // Here's your ticket.
});

// Process job
queue.onJob(function(job, done) {
  // Crunch, crunch... your job processing goes here
  myJobProcessingLogic(job, function(err, result) {
    if (err) return done(err);
    // Must call done when finished
    done(null, result);
  });
});

Configuration

Adrian comes with a few options.

var queue = new Queue('collection-name', {options});

var defaults = {
  maxAttempts : 1,
  maxAge      : false, // maximum age of a job in seconds
  concurrency : 1,
  priority    : 1,
  polling     : 200
};

Similar projects