event

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package event defines the domain-event contract and the in-process synchronous event bus shared by all Tupic services.

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(NewBus),
)

Functions

func NewBus

func NewBus(l logger.Logger) (Publisher, Subscriber)

Types

type Bus

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

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

func (*Bus) Publish

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

func (*Bus) PublishAll

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

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

func (*Bus) Subscribe

func (eb *Bus) Subscribe(eventName string, h Handler)

type DomainEvent

type DomainEvent interface {
	Name() string
}

DomainEvent is the contract every aggregate-raised event implements.

type Handler

type Handler func(ctx context.Context, e DomainEvent) error

Handler reacts to a single domain event.

type Publisher

type Publisher interface {
	Publish(ctx context.Context, e DomainEvent) error
	// PublishAll dispatches events in order, aborting on the first handler error.
	PublishAll(ctx context.Context, events []DomainEvent) error
}

Publisher dispatches domain events to the in-process sync event bus.

type Subscriber

type Subscriber interface {
	Subscribe(eventName string, h Handler)
}

Subscriber registers domain event handlers on the in-process sync event bus.

Jump to

Keyboard shortcuts

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