event

package
v0.0.0-...-ba58dea Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultQueueLength = 10

Variables

This section is empty.

Functions

func Publish

func Publish(bus *Bus, event any)

func PublishContext

func PublishContext(ctx context.Context, bus *Bus, event any) bool

func PublishTry

func PublishTry(bus *Bus, event any) bool

func Subscribe

func Subscribe[E any](bus *Bus, handler Handler[E]) (unsubscribe func())

func SubscribeAll

func SubscribeAll(bus *Bus, handler Handler[any]) (unsubscribe func())

func SubscribeAllFunc

func SubscribeAllFunc(bus *Bus, handler func(ctx context.Context, evt any)) (unsubscribe func())

func SubscribeFunc

func SubscribeFunc[E any](bus *Bus, handler func(ctx context.Context, evt E)) (unsubscribe func())

func WithChan

func WithChan(events chan any) func(*Bus)

func WithQueueLength

func WithQueueLength(length int) func(*Bus)

Types

type Bus

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

func NewBus

func NewBus(options ...func(*Bus)) *Bus

func (*Bus) Chan

func (b *Bus) Chan() chan<- any

func (*Bus) Run

func (b *Bus) Run(ctx context.Context)

func (*Bus) RunOnce

func (b *Bus) RunOnce(ctx context.Context)

type Handler

type Handler[E any] interface {
	Handle(ctx context.Context, evt E)
}

func Func

func Func[E any](lambda func(ctx context.Context, event E)) Handler[E]

Jump to

Keyboard shortcuts

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