eventbus

package
v0.0.0-...-14802c6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventMessage   = "message"
	EventCommand   = "command"
	EventRawUpdate = "raw_update"
	EventShutdown  = "shutdown"
	EventStart     = "start"
	EventError     = "error"
)

Variables

View Source
var ErrHandlerTimeout = errors.New("eventbus: handler timed out")

ErrHandlerTimeout is returned when a handler exceeds its execution deadline.

Functions

This section is empty.

Types

type Bus

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

func New

func New(logger interfaces.Logger) *Bus

func (*Bus) Emit

func (b *Bus) Emit(ctx context.Context, eventType string, data any) error

func (*Bus) EmitAsync

func (b *Bus) EmitAsync(ctx context.Context, eventType string, data any)

func (*Bus) EmitEvent

func (b *Bus) EmitEvent(ctx context.Context, event *Event) error

func (*Bus) Shutdown

func (b *Bus) Shutdown(ctx context.Context) error

func (*Bus) Subscribe

func (b *Bus) Subscribe(eventType string, handler Handler, opts ...Option) *Subscription

func (*Bus) Unsubscribe

func (b *Bus) Unsubscribe(sub *Subscription)

func (*Bus) WaitForShutdown

func (b *Bus) WaitForShutdown() <-chan struct{}

type Event

type Event struct {
	Type      string
	Timestamp time.Time
	Data      any
	Context   context.Context
	Metadata  map[string]any
}

type Handler

type Handler func(ctx context.Context, event *Event) error

type Option

type Option func(*Subscription)

func WithFilter

func WithFilter(f func(*Event) bool) Option

func WithPriority

func WithPriority(p int) Option

type Subscription

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

Jump to

Keyboard shortcuts

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