plugin-queue

The queue plugin implements simple queueing functionality that uses redis as the preferred underlying storage.

Installation and usage
npm i --save thorin-plugin-queue@1.x
'use strict';
// app.js entry file
const thorin = require('thorin');

thorin.addPlugin(require('thorin-plugin-queue'));   // <- add this line
thorin.run((err) => {});

# setup the queue plugin
node app.js --setup=plugin.queue
Default configuration
  • storestringthe redis store name to use for enqueue/dequeue. If no store is given, we will work with an in-memory queue (not suitable for production)
  • channelstring, thorin.queuethe default channel (or list) name used to enqueue/dequeue from
  • logFilestring, thorin.root + config/.queue if specified, this will be the file that we're going to use to write queue logs.
  • logPersistnumber, 1000the number of milliseconds between queue log persistence calls. This is done to minimize the number of lost queue items.
Plugin functionality
pluginObj.create(opt)
Manually create a new queue instance, using the given options
The Queue class
queueObj.enqueue(item, channel, fn)
Enqueues the given item to the queue. If channel is specified, use that one in stead of the default channel.
  • itemanythe item to enqueue to the queue. If it is an object, we will stringify it.
  • channelstringan optional channel name to enqueue it to. Defaults to the configured one.
  • fnfunctionan optional function to call once the item was enqueued.
queueObj.dequeue(count, channel, fn) : Promise
Dequeues the given number of items from the queue. By default, it will only dequeue a single item.
  • countnumber, 1the number of items to dequeue, defaults to 1.
  • channelstringif specified, dequeues from the given channel. Otherwise, defaults to the configured channel.
  • fnfunction if specified, use it as the result callback, otherwise return a Promise.
'use strict';
const queueObj = thorin.plugin('queue');
queueObj.enqueue({myObject: 'right here'});
setTimeout(() => {
   queueObj.dequeue(100, (err, items) => {
      log.info('Items:', items);
   });
}, 1000);
Do you have a question or is something missing?

You can always create a new issue on GitHub or contact one of the core founders by chat.