Interface to many worker queue backends.

npm install que
1 downloads in the last day
2 downloads in the last week
6 downloads in the last month


One interface to many queue & worker backends.


npm install que

Supported backends



var Que = require('que');

Que.connect(['gearman://'], function(){
    // all backends connected

    // all backends disconnected

Defining worker

var EchoReverseWorker = Que.define({
    job: 'echoReverse', // job name
    driver: 'gearman', // driver's name
    process: function(callback) { // processing function
        var result = this.params.message.split('').reverse().join(''); // this.params contains all the data you send, let's just reverse the string
        callback(false, { echo: result }); // first argument specifies error(none, in our case), second - response

Submitting jobs

EchoReverseWorker.submit({ message: '2pac' }, function(err, response){ // second argument is optional
    response.echo == 'cap2'; // true

For CoffeeScript developers

You can define workers using CoffeeScript native class system:

class EchoReverseWorker extends Que.Worker
    job: 'echoReverse'
    driver: 'gearman'

    process: (callback) ->
        result = @params.message.split('').reverse().join('')
        callback false, echo: result

EchoReverseWorker = Que.Workers.setup EchoReverseWorker # this is required

Making own drivers

Your driver should implement this interface:

class SomeDriver
    @connect: (server, callback) ->
        # server is an URI, like protocol://
        # callback should be called when you connect to a backend

    @disconnect: (callback) ->
        # callback should be called when you disconnect from a backend

    @register: (name, handler) ->
        # name is the name of the job
        # handler is the function which handles the job

    @submit: (name, params) ->
        # name is the name of the job
        # params is the data that should be sent

After that, you should register your driver under chosen name:

Que.registerDriver 'someDriver', SomeDriver

Users of your driver will be able to connect to it using URL like someDriver://localhost:port/.


Run all the needed backends and execute mocha in Terminal.



npm loves you