models

package
v0.0.0-...-dc7611c Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateStateProjection

type AggregateStateProjection interface {
	Apply
	// contains filtered or unexported methods
}

type Apply

type Apply interface {
	// Apply a new event to the aggregate state, adds the event to the list of pending changes,
	// and increases the `CurrentVersion` property and `LastCommittedVersion` will be unchanged.
	Apply(event domain.IDomainEvent, isNew bool) error
}

type EventSourcedAggregateRoot

type EventSourcedAggregateRoot struct {
	*domain.Entity
	// contains filtered or unexported fields
}

EventSourcedAggregateRoot base aggregate contains all main necessary fields

func NewEventSourcedAggregateRoot

func NewEventSourcedAggregateRoot(aggregateType string, when WhenFunc) *EventSourcedAggregateRoot

func NewEventSourcedAggregateRootWithId

func NewEventSourcedAggregateRootWithId(
	id uuid.UUID,
	aggregateType string,
	when WhenFunc,
) *EventSourcedAggregateRoot

func (*EventSourcedAggregateRoot) AddDomainEvents

func (a *EventSourcedAggregateRoot) AddDomainEvents(event domain.IDomainEvent) error

func (*EventSourcedAggregateRoot) Apply

func (a *EventSourcedAggregateRoot) Apply(event domain.IDomainEvent, isNew bool) error

func (*EventSourcedAggregateRoot) CurrentVersion

func (a *EventSourcedAggregateRoot) CurrentVersion() int64

func (*EventSourcedAggregateRoot) HasUncommittedEvents

func (a *EventSourcedAggregateRoot) HasUncommittedEvents() bool

func (*EventSourcedAggregateRoot) LoadFromHistory

func (a *EventSourcedAggregateRoot) LoadFromHistory(
	events []domain.IDomainEvent,
	metadata metadata.Metadata,
) error

func (*EventSourcedAggregateRoot) MarkUncommittedEventAsCommitted

func (a *EventSourcedAggregateRoot) MarkUncommittedEventAsCommitted()

func (*EventSourcedAggregateRoot) OriginalVersion

func (a *EventSourcedAggregateRoot) OriginalVersion() int64

func (*EventSourcedAggregateRoot) SetOriginalVersion

func (a *EventSourcedAggregateRoot) SetOriginalVersion(version int64)

func (*EventSourcedAggregateRoot) String

func (a *EventSourcedAggregateRoot) String() string

func (*EventSourcedAggregateRoot) UncommittedEvents

func (a *EventSourcedAggregateRoot) UncommittedEvents() []domain.IDomainEvent

type EventSourcedAggregateRootDataModel

type EventSourcedAggregateRootDataModel struct {
	*domain.EntityDataModel
	OriginalVersion int64 `json:"originalVersion" bson:"originalVersion"`
}

type IEventSourcedAggregateRoot

type IEventSourcedAggregateRoot interface {
	domain.IEntity

	// OriginalVersion Gets the original version is the aggregate version we got from the store. This is used to ensure optimistic concurrency,
	// to check if there were no changes made to the aggregate state between load and save for the current operation.
	OriginalVersion() int64

	SetOriginalVersion(version int64)

	// CurrentVersion Gets the current version is set to original version when the aggregate is loaded from the store.
	// It should increase for each state transition performed within the scope of the current operation.
	CurrentVersion() int64

	// AddDomainEvents adds a new domain_events event to the aggregate's uncommitted events.
	AddDomainEvents(event domain.IDomainEvent) error

	// MarkUncommittedEventAsCommitted Mark all changes (events) as committed, clears uncommitted changes and updates the current version of the aggregate.
	MarkUncommittedEventAsCommitted()

	// HasUncommittedEvents Does the aggregate have change that have not been committed to storage
	HasUncommittedEvents() bool

	// UncommittedEvents Gets a list of uncommitted events for this aggregate.
	UncommittedEvents() []domain.IDomainEvent

	// LoadFromHistory Loads the current state of the aggregate from a list of events.
	LoadFromHistory(events []domain.IDomainEvent, metadata metadata.Metadata) error

	AggregateStateProjection
}

IEventSourcedAggregateRoot contains all methods of AggregateBase

type IHaveEventSourcedAggregate

type IHaveEventSourcedAggregate interface {
	When
	NewEmptyAggregate()
	IEventSourcedAggregateRoot
}

IHaveEventSourcedAggregate this interface should implement by actual aggregate root class in our domain_events

type StreamEvent

type StreamEvent struct {
	EventID  uuid.UUID
	Version  int64
	Position int64
	Event    domain.IDomainEvent
	Metadata metadata.Metadata
}

type When

type When interface {
	// When Update the aggregate state with new events that are added to the event store and also for events that are already in the event store without increasing the version.
	When(event domain.IDomainEvent) error
}

type WhenFunc

type WhenFunc func(event domain.IDomainEvent) error

Directories

Path Synopsis
stream_position

Jump to

Keyboard shortcuts

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