diff options
author | Valery Piashchynski <[email protected]> | 2020-12-26 13:13:59 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-26 13:13:59 +0300 |
commit | 1aaf6e6ffb015cd5a21d9d938ad84c18723973c5 (patch) | |
tree | 7221427ba25f8f99a10720778a420703dc2bff92 /interfaces/events | |
parent | de4d0b6e66ceda08b0daec18a218c1baa71ebf04 (diff) |
Reorganize eventsv2.0.0-beta4
Diffstat (limited to 'interfaces/events')
-rw-r--r-- | interfaces/events/handler.go | 8 | ||||
-rw-r--r-- | interfaces/events/pool_events.go | 8 | ||||
-rw-r--r-- | interfaces/events/worker_events.go | 9 |
3 files changed, 14 insertions, 11 deletions
diff --git a/interfaces/events/handler.go b/interfaces/events/handler.go index 01f64d73..ac6c15a4 100644 --- a/interfaces/events/handler.go +++ b/interfaces/events/handler.go @@ -1,10 +1,14 @@ package events +// Handler interface type Handler interface { + // Return number of active listeners NumListeners() int - AddListener(listener EventListener) + // AddListener adds lister to the publisher + AddListener(listener Listener) + // Push pushes event to the listeners Push(e interface{}) } // Event listener listens for the events produced by worker, worker pool or other service. -type EventListener func(event interface{}) +type Listener func(event interface{}) diff --git a/interfaces/events/pool_events.go b/interfaces/events/pool_events.go index cc32f6b2..d1464e1a 100644 --- a/interfaces/events/pool_events.go +++ b/interfaces/events/pool_events.go @@ -16,16 +16,16 @@ const ( // EventNoFreeWorkers triggered when there are no free workers in the stack and timeout for worker allocate elapsed EventNoFreeWorkers - // todo: EventMaxMemory caused when worker consumes more memory than allowed. + // EventMaxMemory caused when worker consumes more memory than allowed. EventMaxMemory - // todo: EventTTL thrown when worker is removed due TTL being reached. Context is rr.WorkerError + // EventTTL thrown when worker is removed due TTL being reached. Context is rr.WorkerError EventTTL - // todo: EventIdleTTL triggered when worker spends too much time at rest. + // EventIdleTTL triggered when worker spends too much time at rest. EventIdleTTL - // todo: EventExecTTL triggered when worker spends too much time doing the task (max_execution_time). + // EventExecTTL triggered when worker spends too much time doing the task (max_execution_time). EventExecTTL ) diff --git a/interfaces/events/worker_events.go b/interfaces/events/worker_events.go index 497f0a06..2bff1811 100644 --- a/interfaces/events/worker_events.go +++ b/interfaces/events/worker_events.go @@ -1,17 +1,16 @@ package events -// EventWorkerKill thrown after WorkerProcess is being forcefully killed. const ( // EventWorkerError triggered after WorkerProcess. Except payload to be error. - EventWorkerError E = iota + 200 + EventWorkerError W = iota + 200 // EventWorkerLog triggered on every write to WorkerProcess StdErr pipe (batched). Except payload to be []byte string. EventWorkerLog ) -type E int64 +type W int64 -func (ev E) String() string { +func (ev W) String() string { switch ev { case EventWorkerError: return "EventWorkerError" @@ -24,7 +23,7 @@ func (ev E) String() string { // WorkerEvent wraps worker events. type WorkerEvent struct { // Event id, see below. - Event E + Event W // Worker triggered the event. Worker interface{} |