event

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceDefault = "application"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseEvent

type BaseEvent struct {
	ID                 string
	EventTypeValue     string
	OccurredAtValue    time.Time
	AggregateTypeValue string
	AggregateIDValue   string
}

BaseEvent provides the stable event identity and routing fields.

func NewBaseEvent

func NewBaseEvent(eventType, aggregateType, aggregateID string) BaseEvent

func (BaseEvent) AggregateID

func (e BaseEvent) AggregateID() string

func (BaseEvent) AggregateType

func (e BaseEvent) AggregateType() string

func (BaseEvent) EventID

func (e BaseEvent) EventID() string

func (BaseEvent) EventType

func (e BaseEvent) EventType() string

func (BaseEvent) OccurredAt

func (e BaseEvent) OccurredAt() time.Time

type DomainEvent

type DomainEvent interface {
	EventID() string
	EventType() string
	OccurredAt() time.Time
	AggregateType() string
	AggregateID() string
	Payload() any
}

DomainEvent describes a business fact that can be routed through MQ or staged into the transactional outbox.

type Event

type Event[T any] struct {
	BaseEvent
	Data T
}

Event is a generic domain event with a JSON-serializable payload.

func New

func New[T any](eventType, aggregateType, aggregateID string, data T) Event[T]

func (Event[T]) Payload

func (e Event[T]) Payload() any

type Publisher

type Publisher interface {
	Publish(ctx context.Context, event DomainEvent) error
	PublishAll(ctx context.Context, events []DomainEvent) error
}

Publisher publishes events to their configured transport.

type Stager

type Stager interface {
	Stage(ctx context.Context, events ...DomainEvent) error
}

Stager stages durable events inside the caller's active transaction.

Jump to

Keyboard shortcuts

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