Nice Package, Mate

    staque

    0.0.3 • Public • Published

    staque

    build multiple, on-the-fly synchronous job queues

    Build Status

    Usage

    $ npm install staque

    Create a new job queue and load a job.

    var queue = staque.create({
      job: function(task, cb) {  // <- required, the job to run
        console.log(task);
        cb();   
      }, 
      delay: 100,      // <- optional, sets a delay between sub-queue job execution
      concurrency: 0   // <- optional, number of concurrent jobs in each sub-queue
    });
     
    queue.load('blah', function(err) {
      if(!err) console.log('queued a job');
    });
     

    staque also provides sub-queuing. This is useful if you are doing something like queueing jobs by client. Each sub-queue acts independently. To load a job into a sub-queue, just provide a sub-queue key.

    Note: Not providing a sub-queue just puts your job in a queue called _default.

    queue.load('foo task', 'client1', function(err) {
      if(!err) console.log('queued a job in a sub-queue');
    });
     
    queue.load('foo task', function(err) {
      if(!err) console.log('queued a job in the _default queue');
    });

    Callbacks are also optional...

    queue.load('foo task', 'client1');

    You can request the status of your queues with the stat() call. The call will return an array of the queues, current jobs, and other data.

    queue.stat(function(err,stat) {
      if(!err) console.log(stat);
    });

    Keywords

    none

    Install

    npm i staque

    DownloadsWeekly Downloads

    2

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • kevinohara80