From a3ad9d0cb0d58343a7d8da998b46964d37ae4ae7 Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Mon, 14 Feb 2022 18:53:37 +0100 Subject: [PATCH] Move toTheSinks out of for loop --- sinks/sinkManager.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sinks/sinkManager.go b/sinks/sinkManager.go index e2d01a7..bd243f4 100644 --- a/sinks/sinkManager.go +++ b/sinks/sinkManager.go @@ -100,18 +100,17 @@ func (sm *sinkManager) Start() { cclog.ComponentDebug("SinkManager", "DONE") } - for { - - toTheSinks := func(p lp.CCMetric) { - // Send received metric to all outputs - cclog.ComponentDebug("SinkManager", "WRITE", p) - for _, s := range sm.sinks { - if err := s.Write(p); err != nil { - cclog.ComponentError("SinkManager", "WRITE", s.Name(), "write failed:", err.Error()) - } + toTheSinks := func(p lp.CCMetric) { + // Send received metric to all outputs + cclog.ComponentDebug("SinkManager", "WRITE", p) + for _, s := range sm.sinks { + if err := s.Write(p); err != nil { + cclog.ComponentError("SinkManager", "WRITE", s.Name(), "write failed:", err.Error()) } } + } + for { select { case <-sm.done: done()