event

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventQueueSize = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	Data      any
}

func NewEvent

func NewEvent(eventType EventType, eventData any) Event

type EventBus

type EventBus struct {
	// contains filtered or unexported fields
}

func NewEventBus

func NewEventBus(promRegistry prometheus.Registerer) *EventBus

NewEventBus creates a new EventBus

func (*EventBus) Publish

func (e *EventBus) Publish(eventType EventType, evt Event)

Publish allows a producer to send an event of a particular type to all subscribers

func (*EventBus) Subscribe

func (e *EventBus) Subscribe(
	eventType EventType,
) (EventSubscriberId, <-chan Event)

Subscribe allows a consumer to receive events of a particular type via a channel

func (*EventBus) SubscribeFunc

func (e *EventBus) SubscribeFunc(
	eventType EventType,
	handlerFunc EventHandlerFunc,
) EventSubscriberId

SubscribeFunc allows a consumer to receive events of a particular type via a callback function

func (*EventBus) Unsubscribe

func (e *EventBus) Unsubscribe(eventType EventType, subId EventSubscriberId)

Unsubscribe stops delivery of events for a particular type for an existing subscriber

type EventHandlerFunc

type EventHandlerFunc func(Event)

type EventSubscriberId

type EventSubscriberId int

type EventType

type EventType string

Jump to

Keyboard shortcuts

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