ddd

package
v0.0.0-...-0ebfa01 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 7 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 NewAggregate

func NewAggregate(id, name string) *aggregate

func NewEntity

func NewEntity(id, name string) *entity

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 interface {
	IDer
	AggregateNamer
	Eventer
	IDSetter
	NameSetter
}

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 interface {
	IDer
	EntityNamer
	IDSetter
	NameSetter
}

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 {
	SetID(string)
}

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 MockAggregate

type MockAggregate struct {
	mock.Mock
}

MockAggregate is an autogenerated mock type for the Aggregate type

func NewMockAggregate

func NewMockAggregate(t mockConstructorTestingTNewMockAggregate) *MockAggregate

NewMockAggregate creates a new instance of MockAggregate. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockAggregate) AddEvent

func (_m *MockAggregate) AddEvent(_a0 string, _a1 EventPayload, _a2 ...EventOption)

AddEvent provides a mock function with given fields: _a0, _a1, _a2

func (*MockAggregate) AggregateName

func (_m *MockAggregate) AggregateName() string

AggregateName provides a mock function with given fields:

func (*MockAggregate) ClearEvents

func (_m *MockAggregate) ClearEvents()

ClearEvents provides a mock function with given fields:

func (*MockAggregate) Events

func (_m *MockAggregate) Events() []AggregateEvent

Events provides a mock function with given fields:

func (*MockAggregate) ID

func (_m *MockAggregate) ID() string

ID provides a mock function with given fields:

func (*MockAggregate) SetID

func (_m *MockAggregate) SetID(_a0 string)

SetID provides a mock function with given fields: _a0

func (*MockAggregate) SetName

func (_m *MockAggregate) SetName(_a0 string)

SetName provides a mock function with given fields: _a0

type MockCommandHandler

type MockCommandHandler[T Command] struct {
	mock.Mock
}

MockCommandHandler is an autogenerated mock type for the CommandHandler type

func NewMockCommandHandler

func NewMockCommandHandler[T Command](t mockConstructorTestingTNewMockCommandHandler) *MockCommandHandler[T]

NewMockCommandHandler creates a new instance of MockCommandHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockCommandHandler[T]) HandleCommand

func (_m *MockCommandHandler[T]) HandleCommand(ctx context.Context, cmd T) (Reply, error)

HandleCommand provides a mock function with given fields: ctx, cmd

type MockEntity

type MockEntity struct {
	mock.Mock
}

MockEntity is an autogenerated mock type for the Entity type

func NewMockEntity

func NewMockEntity(t mockConstructorTestingTNewMockEntity) *MockEntity

NewMockEntity creates a new instance of MockEntity. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockEntity) EntityName

func (_m *MockEntity) EntityName() string

EntityName provides a mock function with given fields:

func (*MockEntity) ID

func (_m *MockEntity) ID() string

ID provides a mock function with given fields:

func (*MockEntity) SetID

func (_m *MockEntity) SetID(_a0 string)

SetID provides a mock function with given fields: _a0

func (*MockEntity) SetName

func (_m *MockEntity) SetName(_a0 string)

SetName provides a mock function with given fields: _a0

type MockEventHandler

type MockEventHandler[T Event] struct {
	mock.Mock
}

MockEventHandler is an autogenerated mock type for the EventHandler type

func NewMockEventHandler

func NewMockEventHandler[T Event](t mockConstructorTestingTNewMockEventHandler) *MockEventHandler[T]

NewMockEventHandler creates a new instance of MockEventHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockEventHandler[T]) HandleEvent

func (_m *MockEventHandler[T]) HandleEvent(ctx context.Context, event T) error

HandleEvent provides a mock function with given fields: ctx, event

type MockEventPublisher

type MockEventPublisher[T Event] struct {
	mock.Mock
}

MockEventPublisher is an autogenerated mock type for the EventPublisher type

func NewMockEventPublisher

func NewMockEventPublisher[T Event](t mockConstructorTestingTNewMockEventPublisher) *MockEventPublisher[T]

NewMockEventPublisher creates a new instance of MockEventPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockEventPublisher[T]) Publish

func (_m *MockEventPublisher[T]) Publish(ctx context.Context, events ...T) error

Publish provides a mock function with given fields: ctx, events

type MockEventSubscriber

type MockEventSubscriber[T Event] struct {
	mock.Mock
}

MockEventSubscriber is an autogenerated mock type for the EventSubscriber type

func NewMockEventSubscriber

func NewMockEventSubscriber[T Event](t mockConstructorTestingTNewMockEventSubscriber) *MockEventSubscriber[T]

NewMockEventSubscriber creates a new instance of MockEventSubscriber. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockEventSubscriber[T]) Subscribe

func (_m *MockEventSubscriber[T]) Subscribe(handler EventHandler[T], events ...string)

Subscribe provides a mock function with given fields: handler, events

type MockReplyHandler

type MockReplyHandler[T Reply] struct {
	mock.Mock
}

MockReplyHandler is an autogenerated mock type for the ReplyHandler type

func NewMockReplyHandler

func NewMockReplyHandler[T Reply](t mockConstructorTestingTNewMockReplyHandler) *MockReplyHandler[T]

NewMockReplyHandler creates a new instance of MockReplyHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockReplyHandler[T]) HandleReply

func (_m *MockReplyHandler[T]) HandleReply(ctx context.Context, reply T) error

HandleReply provides a mock function with given fields: ctx, reply

type NameSetter

type NameSetter interface {
	SetName(string)
}

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