Skip to content

brickyang/egg-bull

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published