optimize events.Job function name

pull/388/head
Michael Li 10 months ago
parent 35c315a649
commit 7ba82d78bd
No known key found for this signature in database

@ -54,15 +54,15 @@ func RemoveJob(id EntryID) {
_defaultJobManager.Remove(id)
}
// ScheduleJob adds a Job to the Cron to be run on the given schedule.
// Schedule adds a Job to the Cron to be run on the given schedule.
// The job is wrapped with the configured Chain.
func ScheduleJob(job Job) EntryID {
func Schedule(job Job) EntryID {
return _defaultJobManager.Schedule(job)
}
// Schedule adds a Job to the Cron to be run on the given schedule.
// OnTask adds a Job to the Cron to be run on the given schedule.
// The job is wrapped with the configured Chain.
func Schedule(s cron.Schedule, fn JobFn) EntryID {
func OnTask(s cron.Schedule, fn JobFn) EntryID {
job := &simpleJob{
Schedule: s,
Job: fn,

@ -18,7 +18,7 @@ func onMaxOnlineJob() {
if err != nil {
panic(err)
}
events.Schedule(schedule, func() {
events.OnTask(schedule, func() {
onlineUserKeys, err := _wc.Keys(conf.PrefixOnlineUser + "*")
if maxOnline := len(onlineUserKeys); err == nil && maxOnline > 0 {
if _, err = _wc.PutHistoryMaxOnline(maxOnline); err != nil {
@ -30,7 +30,7 @@ func onMaxOnlineJob() {
})
}
func scheduleInnerJobs() {
func scheduleJobs() {
cfg.Not("DisableJobManager", func() {
lazyInitial()
onMaxOnlineJob()

@ -46,8 +46,8 @@ func RouteWeb(e *gin.Engine) {
api.RegisterAlipayPubServant(e, newAlipayPubSrv(ds))
api.RegisterAlipayPrivServant(e, newAlipayPrivSrv(ds, client))
})
// shedule inner jobs if need
scheduleInnerJobs()
// shedule jobs if need
scheduleJobs()
}
// lazyInitial do some package lazy initialize for performance

Loading…
Cancel
Save