egg-queue-bull

1.0.0 • Public • Published

egg-queue-bull

NPM version build status Test coverage

Provide job queue for egg, powered by Bull

Install

$ npm i egg-queue-bull --save

Usage

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

Configuration

// {app_root}/config/config.default.js
exports.queue = {
  delegate: 'queue', // load all queues to `app[delegate]` and `ctx[delegate]`, default to `queue`
  baseDir: 'queue', // load all files in `app/${baseDir}` as queues, default to `queue`
};
 
exports.bull = {
  clients: {
    q1: { name: 'q1' },
    q2: { name: 'q2' },
  },
  default: {
    redis: {
      port: 6379,
      host: '127.0.0.1',
    },
  },
};

Please see Bull for more detail.

Example

// {app_root}/app/queue/video.js
module.exports = app => {
  const queue = app.bull.get('videoQueue');
 
  queue.process((job, done) => {
    job.progress(42);
    done();
  });
 
  return queue;
};
 
// {app_root}/app/controller/video.js
exports.index = function* (ctx) {
  yield ctx.queue.video.add({ video: 'http://example.com/video1.mov' });
};

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-queue-bull

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.9 kB

Total Files

19

Last publish

Collaborators

  • chunkai1312