egg-job
Install
$ npm i egg-job --save
Usage
// {app_root}/config/plugin.jsexportsjob = enable: true package: 'egg-job';
Configuration
// {app_root}/config/config.default.jsexportsjob = client : prefix: 'q' redis: port: 6379 host: '10.0.30.61' password: 'fuckyou' db: 9 // if provided select a non-default redis db options: // see https://github.com/mranney/node_redis#rediscreateclient ;
see config/config.default.js for more detail.
Example
create a job
thisappjob;
job process
// {app_root}/app/job/email.jsconst Subscription = Subscription; //must static { return type: 'worker'//worker or all, please see egg-schedule name: 'download' //job name immediate: false ; } //must async { //process email send thisctxappkue; { //.... //more //.... ; } } moduleexports = email;
job publish
// {app_root}/app/controller/email.js 'use strict';module { Controller async { console; //create a job let result = await thisappjob; //job more var job = ctxappkue; ctxbody = "task comming"; } return emailController;};
Questions & Suggestions
Please open an issue here.