egg-queue-bulls
v1.0.3
Published
egg-queue-bulls
Downloads
4
Maintainers
Readme
egg-bull
Install
$ npm i egg-queue-bulls --save
Usage
// {app_root}/config/plugin.js
exports.queue = {
enable: true,
package: 'egg-queue-bulls',
};
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`,
app: true,
agent: false,
};
exports.bull = {
clients: {
video: { name: 'videoQueue' },
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('video');
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.