event

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 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    `json:"id"`
	EventTypeValue     string    `json:"eventType"`
	OccurredAtValue    time.Time `json:"occurredAt"`
	AggregateTypeValue string    `json:"aggregateType"`
	AggregateIDValue   string    `json:"aggregateID"`
}

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
}

type Event

type Event[T any] struct {
	BaseEvent
	Data T `json:"data"`
}

func New

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

func (Event[T]) Payload

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

type EventCollector

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

func NewEventCollector

func NewEventCollector() *EventCollector

func (*EventCollector) AddEvent

func (c *EventCollector) AddEvent(event DomainEvent)

func (*EventCollector) ClearEvents

func (c *EventCollector) ClearEvents()

func (*EventCollector) Events

func (c *EventCollector) Events() []DomainEvent

func (*EventCollector) HasEvents

func (c *EventCollector) HasEvents() bool

type EventHandler

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

type EventPublisher

type EventPublisher = Publisher

type EventRaiser

type EventRaiser interface {
	Events() []DomainEvent
	ClearEvents()
}

type EventStore

type EventStore interface {
	Save(ctx context.Context, events []DomainEvent) error
	Load(ctx context.Context, aggregateType, aggregateID string) ([]DomainEvent, error)
	LoadFrom(ctx context.Context, aggregateType, aggregateID string, fromVersion int64) ([]DomainEvent, error)
}

type EventSubscriber

type EventSubscriber interface {
	Subscribe(eventType string, handler EventHandler) error
	Start(ctx context.Context) error
	Stop() error
}

type NopEventPublisher

type NopEventPublisher struct{}

func NewNopEventPublisher

func NewNopEventPublisher() *NopEventPublisher

func (*NopEventPublisher) Publish

func (*NopEventPublisher) PublishAll

func (p *NopEventPublisher) PublishAll(_ context.Context, _ []DomainEvent) error

type Publisher

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

type Stager

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

Jump to

Keyboard shortcuts

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