From 27f72997490c5509e4aee530b98ac71ce5b6f156 Mon Sep 17 00:00:00 2001 From: mudler Date: Sun, 14 Apr 2024 16:38:14 +0200 Subject: [PATCH] Fixup timers (?) --- agent/agent.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 106f5e3..8d977c1 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -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) }