Documentation ¶
Index ¶
- type Aggregate
- type AggregateConfig
- type AggregateFactory
- type AggregateRepository
- type AggregateType
- type Command
- type CommandBus
- type CommandConfig
- type CommandHandler
- type CommandType
- type Container
- type Event
- type EventBus
- type EventConfig
- type EventData
- type EventMatcher
- type EventPublisher
- type EventStore
- type EventSubscriber
- type EventType
- type SnapshotRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregate ¶
type Aggregate interface { AggregateID() uuid.UUID AggregateType() AggregateType OriginalVersion() int CurrentVersion() int Changes() []Event TrackChange(...Event) FlushChanges() ApplyEvent(Event) error }
Aggregate is the aggregate of an event stream.
type AggregateConfig ¶
type AggregateConfig interface { Register(AggregateType, AggregateFactory) New(AggregateType, uuid.UUID) (Aggregate, error) Factories() map[AggregateType]AggregateFactory }
AggregateConfig ...
type AggregateRepository ¶
type AggregateRepository interface { Save(ctx context.Context, aggregate Aggregate) error Fetch(ctx context.Context, typ AggregateType, id uuid.UUID, version int) (Aggregate, error) FetchWithBase(ctx context.Context, aggregate Aggregate, version int) (Aggregate, error) FetchLatest(ctx context.Context, typ AggregateType, id uuid.UUID) (Aggregate, error) FetchLatestWithBase(ctx context.Context, aggregate Aggregate) (Aggregate, error) Remove(ctx context.Context, aggregate Aggregate) error }
AggregateRepository ...
type AggregateType ¶
type AggregateType string
AggregateType is the type of an aggregate.
func (AggregateType) String ¶ added in v0.11.0
func (t AggregateType) String() string
type Command ¶
type Command interface { CommandType() CommandType AggregateType() AggregateType AggregateID() uuid.UUID }
Command is a command.
type CommandBus ¶
CommandBus is the command bus.
type CommandConfig ¶
type CommandConfig interface { Register(CommandType, CommandHandler) Handler(CommandType) (CommandHandler, error) Handlers() map[CommandType]CommandHandler }
CommandConfig ...
type CommandHandler ¶
CommandHandler handles commands.
type Container ¶ added in v0.5.0
type Container interface { AggregateConfig() AggregateConfig SetAggregateConfig(AggregateConfig) EventConfig() EventConfig SetEventConfig(EventConfig) CommandConfig() CommandConfig SetCommandConfig(CommandConfig) EventBus() EventBus EventPublisher() EventPublisher EventSubscriber() EventSubscriber SetEventBus(EventBus) EventStore() EventStore SetEventStore(EventStore) CommandBus() CommandBus SetCommandBus(CommandBus) Snapshots() SnapshotRepository SetSnapshots(SnapshotRepository) Aggregates() AggregateRepository SetAggregates(AggregateRepository) }
Container ...
func NewContainer ¶ added in v0.11.0
func NewContainer(aggregates AggregateConfig, events EventConfig, commands CommandConfig) Container
NewContainer ...
type Event ¶
type Event interface { Type() EventType Data() EventData Time() time.Time AggregateType() AggregateType AggregateID() uuid.UUID Version() int }
Event is an event.
type EventBus ¶
type EventBus interface { EventPublisher EventSubscriber }
EventBus is the event bus.
type EventConfig ¶
type EventConfig interface { Register(EventType, EventData) // NewData creates an EventData instance for EventType. // The returned object has to be a non-pointer struct. NewData(EventType) (EventData, error) Protos() map[EventType]EventData }
EventConfig is the configuration for the events.
type EventPublisher ¶
EventPublisher publishes events.
type EventStore ¶
type EventStore interface { Save(ctx context.Context, originalVersion int, events ...Event) error Find(ctx context.Context, aggregateType AggregateType, aggregateID uuid.UUID, version int) (Event, error) Fetch(ctx context.Context, aggregateType AggregateType, aggregateID uuid.UUID, from int, to int) ([]Event, error) FetchAll(ctx context.Context, aggregateType AggregateType, aggregateID uuid.UUID) ([]Event, error) FetchFrom(ctx context.Context, aggregateType AggregateType, aggregateID uuid.UUID, from int) ([]Event, error) FetchTo(ctx context.Context, aggregateType AggregateType, aggregateID uuid.UUID, to int) ([]Event, error) RemoveAll(ctx context.Context, aggregateType AggregateType, aggregateID uuid.UUID) error }
EventStore stores events in a database.
type EventSubscriber ¶
type EventSubscriber interface {
Subscribe(ctx context.Context, types ...EventType) (<-chan Event, error)
}
EventSubscriber subscribes to events.
type SnapshotRepository ¶
type SnapshotRepository interface { Save(ctx context.Context, snap Aggregate) error Find(ctx context.Context, typ AggregateType, id uuid.UUID, version int) (Aggregate, error) Latest(ctx context.Context, typ AggregateType, id uuid.UUID) (Aggregate, error) MaxVersion(ctx context.Context, typ AggregateType, id uuid.UUID, maxVersion int) (Aggregate, error) Remove(ctx context.Context, typ AggregateType, id uuid.UUID, version int) error RemoveAll(ctx context.Context, typ AggregateType, id uuid.UUID) error }
SnapshotRepository ...
Click to show internal directories.
Click to hide internal directories.