Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    mr-wolfpublic

    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) { }
    });

    Keywords

    none

    install

    npm i mr-wolf

    Downloadsweekly downloads

    22

    version

    0.1.1

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar