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 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 Command

type Command interface {
	IDer
	CommandName() string
	Payload() CommandPayload
	Metadata() Metadata
	OccurredAt() time.Time
}

func NewCommand

func NewCommand(name string, payload CommandPayload, options ...CommandOption) Command

type CommandHandler

type CommandHandler[T Command] interface {
	HandleCommand(ctx context.Context, cmd T) (Reply, error)
}

type CommandHandlerFunc

type CommandHandlerFunc[T Command] func(ctx context.Context, cmd T) (Reply, error)

func (CommandHandlerFunc[T]) HandleCommand

func (f CommandHandlerFunc[T]) HandleCommand(ctx context.Context, cmd T) (Reply, error)

type CommandOption

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

type CommandPayload

type CommandPayload any

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
}

func NewEvent

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

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(handler EventHandler[T], events ...string)

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(handler EventHandler[T], events ...string)
}

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
}

type Reply

type Reply interface {
	ID() string
	ReplyName() string
	Payload() ReplyPayload
	Metadata() Metadata
	OccurredAt() time.Time
}

func NewReply

func NewReply(name string, payload ReplyPayload, options ...ReplyOption) Reply

type ReplyHandler

type ReplyHandler[T Reply] interface {
	HandleReply(ctx context.Context, reply T) error
}

type ReplyHandlerFunc

type ReplyHandlerFunc[T Reply] func(ctx context.Context, reply T) error

func (ReplyHandlerFunc[T]) HandleReply

func (f ReplyHandlerFunc[T]) HandleReply(ctx context.Context, reply T) error

type ReplyOption

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

type ReplyPayload

type ReplyPayload any

Jump to

Keyboard shortcuts

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