From 28c63951c32e12111d407ee7c5e34f864315f850 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Fri, 3 Jan 2025 21:40:01 +0100 Subject: Ensure alertJob() runs on the clock Currently it only runs if there are monitor/feedback events. Which is probably fine for the most part, but will be a bit more robust. --- internal/manager/manager.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'internal/manager/manager.go') diff --git a/internal/manager/manager.go b/internal/manager/manager.go index dcb1a37..f8b05fd 100644 --- a/internal/manager/manager.go +++ b/internal/manager/manager.go @@ -82,6 +82,9 @@ func (mgr *Manager) Run(ctx context.Context) error { metadataTicker := time.NewTicker(mgr.MetadataRefreshInterval) defer metadataTicker.Stop() + alertTicker := time.NewTicker(mgr.AlertDelay) + defer alertTicker.Stop() + shutdown := false for { select { @@ -89,6 +92,10 @@ func (mgr *Manager) Run(ctx context.Context) error { if err := mgr.metadataJob(ctx); err != nil { return fmt.Errorf("unable to run metadata job: %v", err) } + case <-alertTicker.C: + if err := mgr.alertJob(); err != nil { + return fmt.Errorf("unable to run alert job: %v\n", err) + } case ev := <-mgr.meventCh: if err := mgr.monitorJob(ev); err != nil { return fmt.Errorf("unable to run monitor job: %v", err) -- cgit v1.2.3