egg-kue-jobs
v1.0.6
Published
kue plugin for egg
Downloads
4
Readme
egg-kue-jobs
Install
$ npm i egg-kue-jobs --save
Usage
// {app_root}/config/plugin.js
exports.kueJobs = {
enable: true,
package: 'egg-kue-jobs',
};
Configuration
// {app_root}/config/config.default.js
exports.kueJobs = {
app: true,
agent: false,
client: {
listen: 3001,
queue: {
prefix: 'q',
redis: 'redis://localhost:6379/0'
},
jobDir: path.join(appInfo.baseDir, 'app/job/kue'),
jobConfig: [{
type: 'helloWorld',
}],
},
};
see config/config.default.js for more detail.
Example
// app/job/kue/hello-world.js
'use strict';
module.exports = app => {
return {
config: null,
initConfig: config => {
this.config = config;
},
registerConsumer: async kueQueue => {
console.log(app);
console.log(kueQueue);
console.log('registerConsumer');
},
produce: async msg => {
const ctx = app.createAnonymousContext();
const kueQueue = app.kue.queue;
console.log(ctx);
console.log(msg);
console.log(kueQueue);
console.log(this.config);
console.log('produce');
},
};
};
Questions & Suggestions
Please open an issue here.