events

package
v2.5.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const UnknownEventType string = "Unknown event type"

Variables

This section is empty.

Functions

This section is empty.

Types

type G

type G int64
const (
	// EventUnaryCallOk represents success unary call response
	EventUnaryCallOk G = iota + 13000

	// EventUnaryCallErr raised when unary call ended with error
	EventUnaryCallErr
)

func (G) String

func (ev G) String() string

type GRPCEvent

type GRPCEvent struct {
	Event G
	// Info contains unary call info.
	Info *grpc.UnaryServerInfo
	// Error associated with event.
	Error error
	// event timings
	Start   time.Time
	Elapsed time.Duration
}

JobEvent represent job event.

type Handler

type Handler interface {
	// NumListeners 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 J

type J int64
const (
	// EventPushOK thrown when new job has been added. JobEvent is passed as context.
	EventPushOK J = iota + 12000

	// EventPushError caused when job can not be registered.
	EventPushError

	// EventJobStart thrown when new job received.
	EventJobStart

	// EventJobOK thrown when job execution is successfully completed. JobEvent is passed as context.
	EventJobOK

	// EventJobError thrown on all job related errors. See JobError as context.
	EventJobError

	// EventPipeActive when pipeline has started.
	EventPipeActive

	// EventPipeStopped when pipeline has been stopped.
	EventPipeStopped

	// EventPipePaused when pipeline has been paused.
	EventPipePaused

	// EventPipeError when pipeline specific error happen.
	EventPipeError

	// EventDriverReady thrown when broken is ready to accept/serve tasks.
	EventDriverReady
)

func (J) String

func (ev J) String() string

type JobEvent

type JobEvent struct {
	Event J
	// String is job id.
	ID string
	// Pipeline name
	Pipeline string
	// Associated driver name (amqp, ephemeral, etc)
	Driver string
	// Error for the jobs/pipes errors
	Error error
	// event timings
	Start   time.Time
	Elapsed time.Duration
}

JobEvent represent job event.

type Listener

type Listener func(event interface{})

Listener .. (type alias) 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

	// EventSupervisorError triggered when supervisor can not complete work.
	EventSupervisorError

	// EventWorkerProcessExit triggered on process wait exit
	EventWorkerProcessExit

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

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{}
	Error   error
}

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
)

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