egg-bull-queue
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

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

Package Sidebar

Install

npm i egg-bull-queue

Weekly Downloads

86

Version

1.2.1

License

MIT

Unpacked Size

8.1 kB

Total Files

8

Last publish

Collaborators

  • brickyang