From daeda2ed532f103954ab23f42f77080fce5cdce3 Mon Sep 17 00:00:00 2001 From: Raphael Deem Date: Tue, 15 May 2018 07:45:41 -0700 Subject: [PATCH] use ticker (#553) * use ticker * stop the ticker --- controller/controller.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 1e84d9a42e..585c205cf8 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -66,14 +66,15 @@ func (c *Controller) RunOnce() error { // Run runs RunOnce in a loop with a delay until stopChan receives a value. func (c *Controller) Run(stopChan <-chan struct{}) { + ticker := time.NewTicker(c.Interval) + defer ticker.Stop() for { err := c.RunOnce() if err != nil { log.Error(err) } - select { - case <-time.After(c.Interval): + case <-ticker.C: case <-stopChan: log.Info("Terminating main controller loop") return