summaryrefslogtreecommitdiff
path: root/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces')
-rw-r--r--interfaces/events/handler.go8
-rw-r--r--interfaces/events/pool_events.go8
-rw-r--r--interfaces/events/worker_events.go9
-rw-r--r--interfaces/worker/factory.go4
4 files changed, 16 insertions, 13 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{}
diff --git a/interfaces/worker/factory.go b/interfaces/worker/factory.go
index 8412428d..376303df 100644
--- a/interfaces/worker/factory.go
+++ b/interfaces/worker/factory.go
@@ -11,10 +11,10 @@ import (
type Factory interface {
// SpawnWorkerWithContext creates new WorkerProcess process based on given command with context.
// Process must not be started.
- SpawnWorkerWithTimeout(context.Context, *exec.Cmd, ...events.EventListener) (BaseProcess, error)
+ SpawnWorkerWithTimeout(context.Context, *exec.Cmd, ...events.Listener) (BaseProcess, error)
// SpawnWorker creates new WorkerProcess process based on given command.
// Process must not be started.
- SpawnWorker(*exec.Cmd, ...events.EventListener) (BaseProcess, error)
+ SpawnWorker(*exec.Cmd, ...events.Listener) (BaseProcess, error)
// Close the factory and underlying connections.
Close() error
}