syncbus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDomainEventBus

func NewDomainEventBus(l logger.Logger, mw ...Middleware) (domainevent.Publisher, domainevent.Subscriber)

NewDomainEventBus builds the bus. Optional middleware wraps every handler; handler panics are always recovered and converted to errors regardless of the middleware set.

Types

type Middleware

type Middleware func(next domainevent.Handler) domainevent.Handler

Middleware wraps a domainevent.Handler to add cross-cutting behaviour (logging, metrics, tracing, recovery). Middleware passed to NewDomainEventBus runs outermost-first around every handler; a built-in recovery layer always sits closest to the handler so a handler panic surfaces as an error to the middleware above it.

type SyncBus

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

SyncBus is an in-memory synchronous event bus for domain events with subscription and publishing capabilities.

func (*SyncBus) Publish

func (eb *SyncBus) Publish(ctx context.Context, e domain.DomainEvent) error

func (*SyncBus) PublishAll

func (eb *SyncBus) PublishAll(ctx context.Context, events []domain.DomainEvent) error

PublishAll dispatches events in order, aborting on the first handler error.

func (*SyncBus) Subscribe

func (eb *SyncBus) Subscribe(eventName string, h domainevent.Handler)

Jump to

Keyboard shortcuts

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