Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
build multiple, on-the-fly synchronous job queues
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

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 sub-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);
});
Something went wrong with that request. Please try again.