@zhuowenli/egg-bull
v0.0.4
Published
🥚 Egg.js middleware for bull
Downloads
2
Readme
egg-bull
🥚 Egg.js middleware for bull
Install
yarn add @zhuowenli/egg-bull
Usage
Plugin
// {app_root}/config/plugin.ts
const plugin: EggPlugin = {
bull: {
enable: true,
package: '@zhuowenli/egg-bull',
},
};
Configuration
Single queue
// {app_root}/config/config.default.ts
config.bull = {
client: {
name: 'queue',
redis: {
host: 'localhost',
port: 6379,
db: 0,
},
},
};
Multiple queue (recommended)
// {app_root}/config/config.default.ts
config.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.