sails-hook-bull
Sails.js hook to use bull package for handling distributed jobs and messages.
Installation
Install it via npm:
npm install sails-hook-bull --save
or
yarn add sails-hook-bull
Requirement: Redis version greater than or equal to 2.8.18 is required.
Configuration
You can set some parameters in config/bull.js
to overrides defaults options for all queues.
moduleexportsbull = redis: port: 6379 host: '127.0.0.1' db: 0 password: ''
See bull.queue for more information.
Examples
Bull queue definition in api/queues/firstQueue.js
moduleexports = queueName: 'first-queue' // if redis already defined as an object, url will be ignored url: 'redis://127.0.0.1:6379' opts: limiter: max: 1000 duration: 5000 process: async { return ; };
You can define queues with options:
moduleexports = queueName: 'my-queue' process: name: 'my-process' concurrency: 1 { // do something... ; } ;
Adding jobs to a queue:
// api/controllers/someController.jsmoduleexports = { sailshooksbullfirstQueue };
License
MIT