Simple multiple queues implementation
If you have different needs regarding the functionality, please add a feature request.
npm install --save multiq
Syntax:
const multiq = new Multiq({ timeout: 100 });
options
object:
timeout
-number
- value in milliseconds
Method put()
return number of documents matching query.
Syntax:
multiq.put(queueName, data, done);
queueName
- queue name
data
- object to put into queue named queueName
done
- callback to be called after the element will be taken from the queue and processed (or after timeout reached)
Method put()
puts object into the queue named queueName
.
Syntax:
multiq.get(queueName, callback);
queueName
- queue name
callback
- callback to be called after the element will be processed.
Method length()
returns number of objects in queue named queueName
.
Syntax:
console.log( multiq.length('some-queue') );
queueName
- queue name
Method isEmpty()
returns true
if queue named queueName
is empty, false
otherwise.
Syntax:
console.log( multiq.isEmpty('some-queue') );
queueName
- queue name
'use strict';
const Multiq = require('multiq');
//const Multiq = require('../');
const multiq = new Multiq({ timeout: 100 });
multiq.put('some-queue', { key: 'value'}, (err) => {
if (err) return console.log('err:', err);
console.log('done');
});
console.log('length:', multiq.length('some-queue') );
console.log('isEmpty:', multiq.isEmpty('some-queue') );
multiq.get('some-queue', (data, done) => {
console.log('got data from queue:', data);
done();
});
github.com npmjs.com travis-ci.org coveralls.io inch-ci.org
MIT