Socket
Book a DemoInstallSign in
Socket

sails-hook-bull

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails-hook-bull

A bull wrapper for sails

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
32
28%
Maintainers
1
Weekly downloads
 
Created
Source

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.

module.exports.bull = {
    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

module.exports = {
  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 job => {
    return doSomething(job.data);
  }
};

You can define queues with options:

module.exports = {
  queueName: 'my-queue',
  process: {
    name: 'my-process',
    concurrency: 1,
    processor: (job, done) => {
      // do something...
      done();
    }
  }
};

Adding jobs to a queue:

// api/controllers/someController.js
module.exports = {
  someAction: function(req, res) {
    sails.hooks.bull.firstQueue.add({
        foo: 'bar'
    })
  }
};

License

MIT

Keywords

sails

FAQs

Package last updated on 01 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.