ddd

package
v0.0.0-...-3a9fddd Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AggregateNameKey    = "aggregate-name"
	AggregateIDKey      = "aggregate-id"
	AggregateVersionKey = "aggregate-version"
)

Variables

This section is empty.

Functions

func NewEvent

func NewEvent(name string, payload EventPayload, options ...EventOption) event

func SetEvents

func SetEvents(events ...Event) registry.BuildOption

func SetID

func SetID(id string) registry.BuildOption

func SetName

func SetName(name string) registry.BuildOption

Types

type Aggregate

type Aggregate struct {
	Entity
	// contains filtered or unexported fields
}

func NewAggregate

func NewAggregate(id, name string) Aggregate

func (*Aggregate) AddEvent

func (a *Aggregate) AddEvent(name string, payload EventPayload, options ...EventOption)

func (Aggregate) AggregateName

func (a Aggregate) AggregateName() string

func (*Aggregate) ClearEvents

func (a *Aggregate) ClearEvents()

func (Aggregate) Events

func (a Aggregate) Events() []AggregateEvent

type AggregateEvent

type AggregateEvent interface {
	Event
	AggregateName() string
	AggregateID() string
	AggregateVersion() int
}

type AggregateNamer

type AggregateNamer interface {
	AggregateName() string
}

type Entity

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

func NewEntity

func NewEntity(id, name string) Entity

func (Entity) EntityName

func (e Entity) EntityName() string

func (Entity) Equals

func (e Entity) Equals(other IDer) bool

func (Entity) ID

func (e Entity) ID() string

type EntityNamer

type EntityNamer interface {
	EntityName() string
}

type Event

type Event interface {
	IDer
	EventName() string
	Payload() EventPayload
	Metadata() Metadata
	OccurredAt() time.Time
}

type EventDispatcher

type EventDispatcher[T Event] struct {
	// contains filtered or unexported fields
}

func NewEventDispatcher

func NewEventDispatcher[T Event]() *EventDispatcher[T]

func (*EventDispatcher[T]) Publish

func (h *EventDispatcher[T]) Publish(ctx context.Context, events ...T) error

func (*EventDispatcher[T]) Subscribe

func (h *EventDispatcher[T]) Subscribe(name string, handler EventHandler[T])

type EventHandler

type EventHandler[T Event] interface {
	HandleEvent(ctx context.Context, event T) error
}

type EventHandlerFunc

type EventHandlerFunc[T Event] func(ctx context.Context, event T) error

func (EventHandlerFunc[T]) HandleEvent

func (f EventHandlerFunc[T]) HandleEvent(ctx context.Context, event T) error

type EventOption

type EventOption interface {
	// contains filtered or unexported methods
}

type EventPayload

type EventPayload interface{}

type EventPublisher

type EventPublisher[T Event] interface {
	Publish(ctx context.Context, events ...T) error
}

type EventSubscriber

type EventSubscriber[T Event] interface {
	Subscribe(name string, handler EventHandler[T])
}

type Eventer

type Eventer interface {
	AddEvent(string, EventPayload, ...EventOption)
	Events() []AggregateEvent
	ClearEvents()
}

type EventsSetter

type EventsSetter interface {
	// contains filtered or unexported methods
}

type IDSetter

type IDSetter interface {
	// contains filtered or unexported methods
}

type IDer

type IDer interface {
	ID() string
}

type Metadata

type Metadata map[string]any

func (Metadata) Del

func (m Metadata) Del(key string)

func (Metadata) Get

func (m Metadata) Get(key string) any

func (Metadata) Set

func (m Metadata) Set(key string, value any)

type NameSetter

type NameSetter interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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