Documentation
¶
Overview ¶
Package bus provides a lightweight, type-safe in-process message bus. Supports 1:N pub/sub and 1:1 typed command routing via TypedBus.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoHandler = errors.New("bus: no handler for key") ErrPanicRecovered = errors.New("panic recovered") )
Functions ¶
func Register ¶
func Register[Req, Res any](b *TypedBus, h TypedHandler[Req, Res])
Register adds a command handler. Last registration wins.
Types ¶
type Bus ¶
type Bus[T any] struct { // contains filtered or unexported fields }
Bus is a generic pub/sub message bus. Safe for concurrent use.
func New ¶
func New[T any](mws ...Middleware[T]) *Bus[T]
New creates a Bus with optional middleware applied to all subscribers.
type Middleware ¶
Middleware wraps a Handler for cross-cutting concerns.
Click to show internal directories.
Click to hide internal directories.