All Projects → brickyang → egg-bull

brickyang / egg-bull

Licence: MIT license
No description, website, or topics provided.

Programming Languages

javascript
184084 projects - #8 most used programming language

NPM version build status Test coverage David deps Known Vulnerabilities npm download

中文版

Plugin to handle jobs and messages with Bull in Egg.js.

Bull is a fast, reliable, Redis-based queue for Node.

Install

$ npm i egg-bull-queue --save

If you use TypeScript:

$ npm i @types/bull --save-dev

Usage

// {app_root}/config/plugin.js
exports.bull = {  // plugin name is 'bull'
  enable: true,
  package: 'egg-bull-queue', // package name is 'egg-bull-queue'
};

Configuration

Single queue

// {app_root}/config/config.default.js
exports.bull = {
  client: {
    name: 'queue',
    redis: {
      host: 'localhost',
      port: 6379,
      db: 0,
    },
  },
};

Multiple queue (recommended)

exports.bull = {
  clients: {
    q1: { name: 'q1' },
    q2: { name: 'q2' },
  },
  default: {
    redis: {
      host: 'localhost',
      port: 6379,
      db: 0,
    },
  },
};

Example

app.bull.process(job => {
  console.log(job.data, job1); // 'this is a job'
});

app.bull.add({ job1: 'this is a job' });

For Bull's api read Reference for more details.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].