Fixup timers (?)

This commit is contained in:
mudler
2024-04-14 16:38:14 +02:00
parent eda99d05f4
commit 27f7299749

View File

@@ -674,6 +674,10 @@ func (a *Agent) Run() error {
case job := <-a.jobQueue:
// Consume the job and generate a response
// TODO: Give a short-term memory to the agent
// stop and drain the timer
if !timer.Stop() {
<-timer.C
}
a.consumeJob(job, UserRole)
timer.Reset(a.options.periodicRuns)
case <-a.context.Done():
@@ -683,8 +687,6 @@ func (a *Agent) Run() error {
if !a.options.standaloneJob {
continue
}
// TODO: We should also do not immediately fire this timer but
// instead have a cool-off timer starting after we received the last job
a.periodicallyRun()
timer.Reset(a.options.periodicRuns)
}