-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: egg-schedule.log && support send with args (#35)
- Loading branch information
1 parent
80252ef
commit 2003369
Showing
20 changed files
with
193 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
module.exports = appInfo => { | ||
const config = {}; | ||
|
||
config.customLogger = { | ||
scheduleLogger: { | ||
consoleLevel: 'NONE', | ||
file: path.join(appInfo.root, 'logs', appInfo.name, 'egg-schedule.log'), | ||
}, | ||
}; | ||
|
||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
module.exports = function(agent) { | ||
class ClusterStrategy extends agent.ScheduleStrategy { | ||
start() { | ||
this.interval = setInterval(() => { | ||
this.sendOne({ foo: 'worker' }); | ||
}, this.schedule.interval); | ||
} | ||
} | ||
agent.schedule.use('cluster', ClusterStrategy); | ||
|
||
class ClusterAllStrategy extends agent.ScheduleStrategy { | ||
start() { | ||
this.interval = setInterval(() => { | ||
this.sendAll({ foo: 'all' }); | ||
}, this.schedule.interval); | ||
} | ||
} | ||
agent.schedule.use('cluster-all', ClusterAllStrategy); | ||
}; |
18 changes: 18 additions & 0 deletions
18
test/fixtures/customTypeParams/app/schedule/cluster-all-clz.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const Subscription = require('egg').Subscription; | ||
|
||
class Interval extends Subscription { | ||
static get schedule() { | ||
return { | ||
type: 'cluster-all', | ||
interval: 4000, | ||
}; | ||
} | ||
|
||
* subscribe(data) { | ||
this.ctx.logger.info('cluster_all_log_clz', data); | ||
} | ||
} | ||
|
||
module.exports = Interval; |
10 changes: 10 additions & 0 deletions
10
test/fixtures/customTypeParams/app/schedule/cluster-all.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
exports.schedule = { | ||
type: 'cluster-all', | ||
interval: 4000, | ||
}; | ||
|
||
exports.task = async function (ctx, data) { | ||
ctx.logger.info('cluster_all_log', data); | ||
}; |
18 changes: 18 additions & 0 deletions
18
test/fixtures/customTypeParams/app/schedule/cluster-clz.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const Subscription = require('egg').Subscription; | ||
|
||
class Interval extends Subscription { | ||
static get schedule() { | ||
return { | ||
type: 'cluster', | ||
interval: 4000, | ||
}; | ||
} | ||
|
||
* subscribe(data) { | ||
this.ctx.logger.info('cluster_log_clz', data); | ||
} | ||
} | ||
|
||
module.exports = Interval; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
exports.schedule = { | ||
type: 'cluster', | ||
interval: 4000, | ||
}; | ||
|
||
exports.task = async function (ctx, data) { | ||
ctx.logger.info('cluster_log', data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "customTypeParams" | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "executeError" | ||
} |
Oops, something went wrong.