event

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MaxEventNum is the initial default size of an event queue.
	// Use GetDefaultEventNum() to read the runtime default,
	// which can be changed via SetDefaultEventNum().
	MaxEventNum = 200
)

Variables

This section is empty.

Functions

func GetDefaultEventNum added in v0.16.2

func GetDefaultEventNum() int

GetDefaultEventNum returns the default event number for Queue

concurrent safe.

func SetDefaultEventNum added in v0.16.2

func SetDefaultEventNum(num int)

SetDefaultEventNum sets the default event number for Queue to num. It only affects queues created after the call; existing queues are not resized. It is not exposed as client/server option because the queue is used for internal debugging workflows, and users do not need to be aware of it.

num must be > 0; non-positive values are ignored and the default remains unchanged. concurrent safe.

Types

type Bus

type Bus interface {
	Watch(event string, callback Callback)
	Unwatch(event string, callback Callback)
	Dispatch(event *Event)
	DispatchAndWait(event *Event)
}

Bus implements the observer pattern to allow event dispatching and watching.

func NewEventBus

func NewEventBus() Bus

NewEventBus creates a Bus.

type Callback

type Callback func(*Event)

Callback is called when the subscribed event happens.

type Event

type Event struct {
	Name   string
	Time   time.Time
	Detail string
	Extra  interface{}
}

Event represents an event.

type Queue

type Queue interface {
	Push(e *Event)
	Dump() interface{}
}

Queue is a ring to collect events.

func NewQueue

func NewQueue(cap int) Queue

NewQueue creates a queue with the given capacity.

Jump to

Keyboard shortcuts

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