hooq
v0.0.3
Published
Pulls from Hooq.io queues
Downloads
3
Readme
hooq
Hooq queueing library - for use with Hooq Queues.
Installing
npm install hooq --save
Using
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);
}
);
Methods
new Hooq(options)
Used to setup the Hooq library.
watch(haveMessageCallback, noMessageCallback, errorCallback)
Called when a response comes back
haveMessageCallback(message, done)
Call done()
when you've finished processing an item to avoid reprocessing it.
noMessageCallback()
Called when no new items
errorCallback(error)
Called when there's been an error
Options
Options are passed in when creating your Hooq object
Required
apiKey
- Your API keyqueueKey
- Your queue key
Optional
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)