Hooq queueing library - for use with Hooq Queues.
npm install hooq --save
The library automatically sets up a interval that watches for new items on the queue.
var hooq = require('hooq');
var queueProcessor = new hooq(
{
apiKey: 'Your API Key',
queueKey: 'Your queue key',
}
);
queueProcessor.watch(
function (webhook, done) {
console.log("Message received!");
console.log(webhook);
done();
},
function () {
console.log("No messages");
},
function (err) {
console.log("There has been an error", err);
}
);
new Hooq(options)
Used to setup the Hooq library.
watch(haveMessageCallback, noMessageCallback, errorCallback)
Called when a response comes back
Call done()
when you've finished processing an item to avoid reprocessing it.
Called when no new items
Called when there's been an error
Options are passed in when creating your Hooq object
apiKey
- Your API keyqueueKey
- Your queue key
interval
- How often to check for new items, in seconds (default 5 seconds, min 1 second)take
- Number of items to get at a time (default 1)timeout
- How long the items should stay hidden in the queue before appear again (default 5 minutes)server
- Hooq server URLprotocol
- Protocol to use (http/https)