eventbus

package
v1.26.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	BusSubscriber
	BusPublisher
}

func New

func New(opts ...Option) Bus

type BusPublisher

type BusPublisher interface {
	PublishSync(ctx context.Context, event Event) PublishResult
	PublishAsync(ctx context.Context, event Event) <-chan PublishResult
}

type BusSubscriber

type BusSubscriber interface {
	Subscribe(eventID EventID, cb EventHandler) Subscription
	Unsubscribe(id Subscription)
}

type Event

type Event interface {
	EventID() EventID
}

type EventHandler

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

type EventID

type EventID string

type FailureHook

type FailureHook func(HandlerFailure)

func SlogFailureHook

func SlogFailureHook(logger *slog.Logger) FailureHook

type HandlerFailure

type HandlerFailure struct {
	Subscription Subscription
	Event        Event
	Err          error
	Panic        any
}

type Option

type Option func(*bus)

func WithFailureHook

func WithFailureHook(hook FailureHook) Option

func WithPublishTimeout

func WithPublishTimeout(timeout time.Duration) Option

type PublishResult

type PublishResult struct {
	Delivered int
	Pending   int
	Errors    []error
	Err       error
}

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