From 77c9001ed111d7bfc0df9a4db452c6f0a9e64ec3 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Thu, 4 Feb 2021 09:37:44 +0200 Subject: [PATCH] optimize health_status event handling --- connector/docker.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/connector/docker.go b/connector/docker.go index f93e47f..9fae8be 100644 --- a/connector/docker.go +++ b/connector/docker.go @@ -87,16 +87,10 @@ func (cm *Docker) watchEvents() { for e := range events { actionName := e.Action - // Action may have additional param i.e. "health_status: healthy" - // We need to strip to have only action name - sepIdx := strings.Index(actionName, ": ") - if sepIdx != -1 { - actionName = actionName[:sepIdx] - } - switch actionName { // most frequent event is a health checks - case "health_status": + case "health_status: healthy", "health_status: unhealthy": + sepIdx := strings.Index(actionName, ": ") healthStatus := e.Action[sepIdx+2:] if log.IsEnabledFor(logging.DEBUG) { log.Debugf("handling docker event: action=health_status id=%s %s", e.ID, healthStatus)