From 35349262cee830c69c9b3b36dae1db5ef3eb7bbb Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 28 May 2021 14:00:23 +0200 Subject: [PATCH] Use time.NewTicker(), not time.Tick() --- pkg/icingaredis/heartbeat.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/icingaredis/heartbeat.go b/pkg/icingaredis/heartbeat.go index bbb160c2..bc5e2c0e 100644 --- a/pkg/icingaredis/heartbeat.go +++ b/pkg/icingaredis/heartbeat.go @@ -84,7 +84,9 @@ func (h Heartbeat) controller() { // Message producer loop g.Go(func() error { // We expect heartbeats every second but only read them every 3 seconds - throttle := time.Tick(time.Second * 3) + throttle := time.NewTicker(time.Second * 3) + defer throttle.Stop() + for { cmd := h.client.XRead(ctx, &redis.XReadArgs{ Streams: []string{"icinga:stats", "$"}, @@ -102,7 +104,7 @@ func (h Heartbeat) controller() { return ctx.Err() } - <-throttle + <-throttle.C } })