egg-bull-new
v1.1.2
Published
bull plugin for egg framework
Downloads
46
Maintainers
Readme
egg-bull-new
Install
$ npm i egg-bull-new --save
Usage
// {app_root}/config/plugin.js
exports.bull = {
enable: true,
package: 'egg-bull-new',
};
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,
},
},
};
see config/config.default.js 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
async function (ctx) {
await ctx.queue.video.add({ video: 'http://example.com/video1.mov' });
};
For Bull's api read Reference for more details.