egg-queue-bull
v1.0.0
Published
Provide job queue for egg, powered by Bull
Downloads
26
Maintainers
Readme
egg-queue-bull
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.