Versions in this module Expand all Collapse all v0 v0.0.1 Oct 5, 2022 Changes in this version + func GetId() (uuid.UUID, error) + func GetTx(ctx context.Context) T + type ActorRepository struct + func GetActorRepositoryFor(storage Storage) ActorRepository[T] + func (repository ActorRepository[T]) Fetch(ids spry.Identifiers) (T, error) + func (repository ActorRepository[T]) Handle(command spry.Command) spry.Results[T] + type AggregateIdMap struct + ActorId uuid.UUID + ActorName string + Aggregated AggregatedIds + func CreateAggregateIdMap(actorName string, actorId uuid.UUID) AggregateIdMap + func EmptyAggregateIdMap() AggregateIdMap + func (idMap *AggregateIdMap) AddIdsFor(child string, id ...uuid.UUID) + type AggregateRepository struct + func GetAggregateRepositoryFor(storage Storage) AggregateRepository[T] + func (repository AggregateRepository[T]) Fetch(ids spry.Identifiers) (T, error) + func (repository AggregateRepository[T]) Handle(command spry.Command) spry.Results[T] + type AggregatedIds = map[string][]uuid.UUID + type Caster = func(any) (any, error) + type CommandRecord struct + CreatedOn time.Time + Data any + HandledBy uuid.UUID + HandledOn time.Time + HandledVersion uint64 + Id uuid.UUID + Namespace string + ReceivedOn time.Time + Type string + func NewCommandRecord(command spry.Command) (CommandRecord, error) + func (command CommandRecord) IsValid() bool + type CommandStore interface + Add func(context.Context, string, CommandRecord) error + type EventRecord struct + ActorId uuid.UUID + ActorName string + ActorNamespace string + CreatedBy string + CreatedById uuid.UUID + CreatedByVector string + CreatedByVersion uint64 + CreatedOn time.Time + Data any + Id uuid.UUID + InitiatedBy string + InitiatedById uuid.UUID + Type string + func NewEventRecord(event spry.Event) (EventRecord, error) + func (event EventRecord) IsValid() bool + type EventStore interface + Add func(context.Context, []EventRecord) error + FetchAggregatedSince func(context.Context, string, uuid.UUID, uuid.UUID, LastEventMap, TypeMap) ([]EventRecord, error) + FetchSince func(context.Context, string, uuid.UUID, uuid.UUID, TypeMap) ([]EventRecord, error) + type IdAssignment struct + ActorName string + AssignedId uuid.UUID + Identifiers spry.Identifiers + Json string + func NewAssignment(name string, ids spry.Identifiers, id uuid.UUID) IdAssignment + type IdAssignments struct + func NewAssignments(aggregateName string) IdAssignments + func (a *IdAssignments) AddAssignment(name string, ids spry.Identifiers, id uuid.UUID) + func (a *IdAssignments) CreateAssignment(name string, ids spry.Identifiers) uuid.UUID + func (a *IdAssignments) GetAggregateId() uuid.UUID + func (a *IdAssignments) GetIdFor(name string, ids spry.Identifiers) uuid.UUID + type LastEventMap struct + LastEvents map[string]map[uuid.UUID]uuid.UUID + func CreateLastEvents() LastEventMap + func (last *LastEventMap) AddLastEventFor(child string, childId uuid.UUID, lastEventId uuid.UUID) + func (last *LastEventMap) UpdateFromMap(idMap AggregateIdMap) + type MapStore interface + AddId func(context.Context, string, spry.Identifiers, uuid.UUID) error + AddLink func(context.Context, string, uuid.UUID, string, uuid.UUID) error + GetId func(context.Context, string, spry.Identifiers) (uuid.UUID, error) + GetIdMap func(context.Context, string, uuid.UUID) (AggregateIdMap, error) + type NoOpTx struct + func (tx NoOpTx) Commit() error + func (tx NoOpTx) Rollback() error + type Repository struct + ActorName string + ActorType reflect.Type + Mapping TypeMap + Storage Storage + func (repository Repository[T]) Apply(events []spry.Event, actor T) T + type Snapshot struct + ActorId uuid.UUID + Ancestor string + CreatedOn time.Time + Data any + EventSinceSnapshot int + EventsApplied uint64 + Id uuid.UUID + LastCommandId uuid.UUID + LastCommandOn time.Time + LastEventId uuid.UUID + LastEventOn time.Time + Type string + Vector string + Version uint64 + func NewSnapshot(actor any) (Snapshot, error) + func (snapshot Snapshot) IsValid() bool + type SnapshotStore interface + Add func(context.Context, string, Snapshot, bool) error + Fetch func(context.Context, string, uuid.UUID) (Snapshot, error) + type Storage interface + AddCommand func(context.Context, string, CommandRecord) error + AddEvents func(context.Context, []EventRecord) error + AddLink func(context.Context, string, uuid.UUID, string, uuid.UUID) error + AddMap func(context.Context, string, spry.Identifiers, uuid.UUID) error + AddSnapshot func(context.Context, string, Snapshot, bool) error + Commit func(context.Context) error + FetchAggregatedEventsSince func(context.Context, string, uuid.UUID, uuid.UUID, LastEventMap) ([]EventRecord, error) + FetchEventsSince func(context.Context, string, uuid.UUID, uuid.UUID) ([]EventRecord, error) + FetchId func(context.Context, string, spry.Identifiers) (uuid.UUID, error) + FetchIdMap func(context.Context, string, uuid.UUID) (AggregateIdMap, error) + FetchLatestSnapshot func(context.Context, string, uuid.UUID) (Snapshot, error) + GetContext func(context.Context) (context.Context, error) + RegisterPrimitives func(...any) + Rollback func(context.Context) error + func NewStorage(commands CommandStore, events EventStore, maps MapStore, ...) Storage + type Stores struct + Commands CommandStore + Events EventStore + Maps MapStore + Primitives TypeMap + Snapshots SnapshotStore + Transactions TxProvider[Tx] + func (storage Stores[Tx]) AddCommand(ctx context.Context, actorName string, command CommandRecord) error + func (storage Stores[Tx]) AddEvents(ctx context.Context, events []EventRecord) error + func (storage Stores[Tx]) AddLink(ctx context.Context, parentName string, parentId uuid.UUID, childName string, ...) error + func (storage Stores[Tx]) AddMap(ctx context.Context, actorName string, identifiers spry.Identifiers, ...) error + func (storage Stores[Tx]) AddSnapshot(ctx context.Context, actorName string, snapshot Snapshot, allowPartition bool) error + func (storage Stores[Tx]) Commit(ctx context.Context) error + func (storage Stores[Tx]) FetchAggregatedEventsSince(ctx context.Context, actorName string, actorId uuid.UUID, eventId uuid.UUID, ...) ([]EventRecord, error) + func (storage Stores[Tx]) FetchEventsSince(ctx context.Context, actorName string, actorId uuid.UUID, eventId uuid.UUID) ([]EventRecord, error) + func (storage Stores[Tx]) FetchId(ctx context.Context, actorName string, identifiers spry.Identifiers) (uuid.UUID, error) + func (storage Stores[Tx]) FetchIdMap(ctx context.Context, actorName string, actorId uuid.UUID) (AggregateIdMap, error) + func (storage Stores[Tx]) FetchLatestSnapshot(ctx context.Context, actorName string, actorId uuid.UUID) (Snapshot, error) + func (storage Stores[Tx]) GetContext(ctx context.Context) (context.Context, error) + func (storage Stores[Tx]) RegisterPrimitives(types ...any) + func (storage Stores[Tx]) Rollback(ctx context.Context) error + type StringTemplate struct + func CreateTemplateFromFS(files fs.FS, paths ...string) (*StringTemplate, error) + func (st StringTemplate) Execute(name string, data any) (string, error) + type TxProvider interface + Commit func(ctx context.Context) error + GetTransaction func(ctx context.Context) (T, error) + Rollback func(ctx context.Context) error + type TypeMap struct + Commands map[string]Caster + Events map[string]Caster + func CreateTypeMap() TypeMap + func (m TypeMap) AddTypes(types ...any) + func (m TypeMap) AsCommand(commandType string, v any) (spry.Command, error) + func (m TypeMap) AsEvent(eventType string, v any) (spry.Event, error)