summaryrefslogtreecommitdiff
path: root/util/events.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-17 12:13:55 +0300
committerGitHub <[email protected]>2020-12-17 12:13:55 +0300
commitee0cb478c74c393a35155c2bf51e1ef260e0e5e2 (patch)
tree2c99d4c6e2b2e9e3fa155d5d68a9d471c9aeeb9b /util/events.go
parenta1dc59cabb6e63eab232922f4eb5a19dbd168f44 (diff)
parentedf924b37bcdad14eb31014c571ab58720aa178f (diff)
Merge pull request #452 from spiral/refactor/splitv2.0.0-alpha23
Refactor/split
Diffstat (limited to 'util/events.go')
-rwxr-xr-xutil/events.go36
1 files changed, 0 insertions, 36 deletions
diff --git a/util/events.go b/util/events.go
deleted file mode 100755
index 43a3e646..00000000
--- a/util/events.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package util
-
-type EventsHandler interface {
- NumListeners() int
- AddListener(listener EventListener)
- Push(e interface{})
-}
-
-// Event listener listens for the events produced by worker, worker pool or other service.
-type EventListener func(event interface{})
-
-// EventHandler helps to broadcast events to multiple listeners.
-type EventHandler struct {
- listeners []EventListener
-}
-
-func NewEventsHandler() EventsHandler {
- return &EventHandler{listeners: make([]EventListener, 0, 2)}
-}
-
-// NumListeners returns number of event listeners.
-func (eb *EventHandler) NumListeners() int {
- return len(eb.listeners)
-}
-
-// AddListener registers new event listener.
-func (eb *EventHandler) AddListener(listener EventListener) {
- eb.listeners = append(eb.listeners, listener)
-}
-
-// Push broadcast events across all event listeners.
-func (eb *EventHandler) Push(e interface{}) {
- for _, listener := range eb.listeners {
- listener(e)
- }
-}