From f80d7182ca42f67cc255dc6046b087ff1bed336e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 12 Jun 2024 01:21:51 +0200 Subject: [PATCH] cli/command: remove deprecated EventHandler, InitEventHandler These were deprecated in 46afd26c45771a954871ea5960b7c580d525424b in v26.0, and have no known users. Signed-off-by: Sebastiaan van Stijn --- cli/command/events_utils.go | 51 ------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 cli/command/events_utils.go diff --git a/cli/command/events_utils.go b/cli/command/events_utils.go deleted file mode 100644 index bb656fbf90..0000000000 --- a/cli/command/events_utils.go +++ /dev/null @@ -1,51 +0,0 @@ -package command - -import ( - "sync" - - "github.com/docker/docker/api/types/events" - "github.com/sirupsen/logrus" -) - -// EventHandler is abstract interface for user to customize -// own handle functions of each type of events -// -// Deprecated: EventHandler is no longer used, and will be removed in the next release. -type EventHandler interface { - Handle(action events.Action, h func(events.Message)) - Watch(c <-chan events.Message) -} - -// InitEventHandler initializes and returns an EventHandler -// -// Deprecated: InitEventHandler is no longer used, and will be removed in the next release. -func InitEventHandler() EventHandler { - return &eventHandler{handlers: make(map[events.Action]func(events.Message))} -} - -type eventHandler struct { - handlers map[events.Action]func(events.Message) - mu sync.Mutex -} - -func (w *eventHandler) Handle(action events.Action, h func(events.Message)) { - w.mu.Lock() - w.handlers[action] = h - w.mu.Unlock() -} - -// Watch ranges over the passed in event chan and processes the events based on the -// handlers created for a given action. -// To stop watching, close the event chan. -func (w *eventHandler) Watch(c <-chan events.Message) { - for e := range c { - w.mu.Lock() - h, exists := w.handlers[e.Action] - w.mu.Unlock() - if !exists { - continue - } - logrus.Debugf("event handler: received event: %v", e) - go h(e) - } -}