event

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MaxEventNum is the default size of a event queue.
	MaxEventNum = 200
)

Variables

This section is empty.

Functions

This section is empty.

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