+ ScheduleTimerFuncOnce
This commit is contained in:
@@ -169,6 +169,7 @@ func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime ti
|
||||
return hint, err
|
||||
}
|
||||
|
||||
// 按时间序列循环
|
||||
func ScheduleTimerFunc(name string, handler func(), timeList []string) {
|
||||
now := time.Now()
|
||||
nextTime := jxutils.GetNextTimeFromList(now, timeList)
|
||||
@@ -181,6 +182,18 @@ func ScheduleTimerFunc(name string, handler func(), timeList []string) {
|
||||
})
|
||||
}
|
||||
|
||||
// 按时间调度一次
|
||||
func ScheduleTimerFuncOnce(name string, handler func(), timeStr string) {
|
||||
now := time.Now()
|
||||
nextTime := jxutils.GetNextTimeFromList(now, []string{timeStr})
|
||||
duration := nextTime.Sub(now) + 1*time.Second
|
||||
globals.SugarLogger.Debugf("ScheduleTimerFuncOnce, func:%s, duration:%v", name, duration)
|
||||
utils.AfterFuncWithRecover(duration, func() {
|
||||
globals.SugarLogger.Debugf("ScheduleTimerFuncOnce func:%s", name)
|
||||
handler()
|
||||
})
|
||||
}
|
||||
|
||||
func ScheduleTimerFuncByInterval(handler func(), delay, inerval time.Duration) {
|
||||
globals.SugarLogger.Debugf("ScheduleTimerFuncByInterval, delay:%v, inerval:%v", delay, inerval)
|
||||
utils.AfterFuncWithRecover(delay, func() {
|
||||
|
||||
Reference in New Issue
Block a user