events

package
v2.0.0-beta11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 0 Imported by: 0

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

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 + 7800

	// 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
)

TODO event numbers

func (P) String

func (ev P) String() string

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 + 200

	// EventWorkerLog triggered on every write to WorkerProcess StdErr pipe (batched). Except payload to be []byte string.
	EventWorkerLog
)

func (W) String

func (ev W) String() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL