Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface { // Return number of active listeners NumListeners() int // AddListener adds lister to the publisher AddListener(listener Listener) // Push pushes event to the listeners Push(e interface{}) }
Handler interface
func NewEventsHandler ¶
func NewEventsHandler() Handler
type HandlerImpl ¶
type HandlerImpl struct { sync.RWMutex // all receivers should be pointers // contains filtered or unexported fields }
HandlerImpl helps to broadcast events to multiple listeners.
func (*HandlerImpl) AddListener ¶
func (eb *HandlerImpl) AddListener(listener Listener)
AddListener registers new event listener.
func (*HandlerImpl) NumListeners ¶
func (eb *HandlerImpl) NumListeners() int
NumListeners returns number of event listeners.
func (*HandlerImpl) Push ¶
func (eb *HandlerImpl) Push(e interface{})
Push broadcast events across all event listeners.
type Listener ¶
type Listener func(event interface{})
Event listener listens for the events produced by worker, worker pool or other service.
type P ¶
type P int64
const ( // EventWorkerConstruct thrown when new worker is spawned. EventWorkerConstruct P = iota + 10000 // EventWorkerDestruct thrown after worker destruction. EventWorkerDestruct // EventPoolError caused on pool wide errors. EventPoolError // EventSupervisorError triggered when supervisor can not complete work. EventSupervisorError // EventNoFreeWorkers triggered when there are no free workers in the stack and timeout for worker allocate elapsed EventNoFreeWorkers // EventMaxMemory caused when worker consumes more memory than allowed. EventMaxMemory // EventTTL thrown when worker is removed due TTL being reached. TTL defines maximum time worker is allowed to live (seconds) EventTTL // EventIdleTTL triggered when worker spends too much time at rest. EventIdleTTL // EventExecTTL triggered when worker spends too much time doing the task (max_execution_time). EventExecTTL // EventPoolRestart triggered when pool restart is needed EventPoolRestart )
TODO event numbers
type PoolEvent ¶
type PoolEvent struct { // Event type, see below. Event P // Payload depends on event type, typically it's worker or error. Payload interface{} }
PoolEvent triggered by pool on different events. Pool as also trigger WorkerEvent in case of log.
type W ¶
type W int64
const ( // EventWorkerError triggered after WorkerProcess. Except payload to be error. EventWorkerError W = iota + 11000 // EventWorkerLog triggered on every write to WorkerProcess StdErr pipe (batched). Except payload to be []byte string. EventWorkerLog // EventWorkerStderr is the worker standard error output EventWorkerStderr )
type WorkerEvent ¶
type WorkerEvent struct { // Event id, see below. Event W // Worker triggered the event. Worker interface{} // Event specific payload. Payload interface{} }
WorkerEvent wraps worker events.
Click to show internal directories.
Click to hide internal directories.