event

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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