Skip to content

Commit

Permalink
optimize health_status event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
stokito committed Feb 4, 2021
1 parent d98ce10 commit 77c9001
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions connector/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 77c9001

Please sign in to comment.