summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-17 02:34:44 +0300
committerValery Piashchynski <[email protected]>2020-12-17 02:34:44 +0300
commit9d5fe4f6a98b30fd73be8259f84fa595ac994a71 (patch)
treee49c46b03d8facc73e96f1b6247d83367cc65398 /util
parent1033c25b6bfc752d6059e446510f651e22cbf49b (diff)
huge refactor
Diffstat (limited to 'util')
-rwxr-xr-xutil/events.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/util/events.go b/util/events.go
index 43a3e646..8aa5a1c6 100755
--- a/util/events.go
+++ b/util/events.go
@@ -1,21 +1,14 @@
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{})
+import "github.com/spiral/roadrunner/v2/interfaces/worker"
// EventHandler helps to broadcast events to multiple listeners.
type EventHandler struct {
- listeners []EventListener
+ listeners []worker.EventListener
}
-func NewEventsHandler() EventsHandler {
- return &EventHandler{listeners: make([]EventListener, 0, 2)}
+func NewEventsHandler() worker.EventsHandler {
+ return &EventHandler{listeners: make([]worker.EventListener, 0, 2)}
}
// NumListeners returns number of event listeners.
@@ -24,7 +17,7 @@ func (eb *EventHandler) NumListeners() int {
}
// AddListener registers new event listener.
-func (eb *EventHandler) AddListener(listener EventListener) {
+func (eb *EventHandler) AddListener(listener worker.EventListener) {
eb.listeners = append(eb.listeners, listener)
}