templating: Rework timers
This commit is contained in:
parent
66eb13df30
commit
2d163a4dad
9 changed files with 232 additions and 46 deletions
|
|
@ -119,18 +119,18 @@ func (control *Cron) Start(ctx context.Context, signal <-chan struct{}) <-chan s
|
|||
run()
|
||||
zerolog.Ctx(ctx).Debug().Msg("Cron() beginnning scheduling")
|
||||
|
||||
timer := timex.NewTimer()
|
||||
t := timex.NewTimer()
|
||||
defer timex.ReleaseTimer(t)
|
||||
for {
|
||||
timex.StopTimer(timer)
|
||||
timer.Reset(control.Config.CronInterval)
|
||||
timex.StopTimer(t)
|
||||
t.Reset(control.Config.CronInterval)
|
||||
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-t.C:
|
||||
zerolog.Ctx(ctx).Debug().Msg("Cron() timer fired")
|
||||
case <-signal:
|
||||
zerolog.Ctx(ctx).Debug().Msg("Cron() received signal")
|
||||
case <-ctx.Done():
|
||||
timex.StopTimer(timer)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue