From 9d5fe4f6a98b30fd73be8259f84fa595ac994a71 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Thu, 17 Dec 2020 02:34:44 +0300 Subject: huge refactor --- util/events.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'util') 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) } -- cgit v1.2.3