0.1.1 • Published 12 years ago

mr-wolf v0.1.1

Weekly downloads
56
License
-
Repository
github
Last release
12 years ago

mr-wolf

Distributed work-queue for nodejs

Installation

$ npm install mr-wolf

Usage

Create a job

Place your work in the default /jobs-directory. Note that you can change the location of this directory using

mrWolf.setJobDirectory('./some/other/place');

example: /jobs/sendEmail.js

module.exports = {
  //A job must implement the receive-method that takes two parameters
  //meta : the meta-data sent to the job
  //callback : a callback with one parameter : error (if any)
  receive : function(meta, callback) {
    sendEmail(meta.recipient, meta.title, meta.body, function(err) {
      callback(err);
    });
  }
};

Enqueue a work-item

var mrWolf = require('mr-wolf');
//Push takes two arguments, 
//the job-name (should be equivalent to the fileName mentioned in create a job)
//and the meta-data, which will also be supplied to the job.
mrWolf.enqueue('sendEmail', {
  recipient : "mr.recipient@coolmail.com",
  title : 'Hello mr!',
  body : 'Its a fifteen minute drive, I\'ll be there in five'
});

Start working

Note that starting mr-wolf on many servers lets them share the work-load and process the queue faster.

Here's how you get start it up:

mrWolf.start({
  //Add some listeners (optional)
  onError : function(job, error) { },
  onStart : function(job) { },
  onComplete : function(job) { },
  onEnqueue : function(job) { }
});
0.1.1

12 years ago

0.1.0

12 years ago

0.0.9

12 years ago

0.0.8

12 years ago

0.0.7

12 years ago

0.0.6

12 years ago

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago