aggregate

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRetry added in v2.2.4

func HandleRetry(ctx context.Context, retryFunc RetryFunc) error

Types

type AdditionalModel added in v2.18.0

type AdditionalModel struct {
	GroupID     string
	AggregateID string
}

type Aggregate

type Aggregate struct {
	LogDebugfFunc eventstore.LogDebugfFunc
	// contains filtered or unexported fields
}

Aggregate holds data for Handle command

func NewAggregate

func NewAggregate(groupID, aggregateID string, retryFunc RetryFunc, store eventstore.EventStore, factoryModel FactoryModelFunc, logDebugfFunc eventstore.LogDebugfFunc, additionalModels ...AdditionalModel) (*Aggregate, error)

NewAggregate creates aggregate. it load and store events created from commands

func (*Aggregate) AggregateID

func (a *Aggregate) AggregateID() string

func (*Aggregate) FactoryModel added in v2.2.4

func (a *Aggregate) FactoryModel(ctx context.Context, groupID, aggregateID string) (AggregateModel, error)

func (*Aggregate) GroupID

func (a *Aggregate) GroupID() string

func (*Aggregate) HandleCommand

func (a *Aggregate) HandleCommand(ctx context.Context, cmd Command) ([]eventstore.Event, error)

HandleCommand transforms command to a event, store and publish eventstore.

func (*Aggregate) HandleCommandWithAggregateModelWrapper added in v2.7.0

func (a *Aggregate) HandleCommandWithAggregateModelWrapper(ctx context.Context, cmd Command, amodel *AggregateModelWrapper) (events []eventstore.Event, concurrencyExcpetion bool, err error)

type AggregateModel

type AggregateModel = interface {
	eventstore.Model

	HandleCommand(ctx context.Context, cmd Command, newVersion uint64) ([]eventstore.Event, error)
	TakeSnapshot(version uint64) (snapshotEvent eventstore.Event, ok bool)
	GroupID() string // defines group where model belows
}

AggregateModel user model for aggregate need to satisfy this interface.

type AggregateModelWrapper added in v2.7.0

type AggregateModelWrapper struct {
	// contains filtered or unexported fields
}

func NewAggregateModel added in v2.7.0

func NewAggregateModel(ctx context.Context, groupID, aggregateID string, store eventstore.EventStore, logDebugfFunc eventstore.LogDebugfFunc, factoryModel FactoryModelFunc, additionalModels ...AdditionalModel) (*AggregateModelWrapper, error)

func (*AggregateModelWrapper) GroupID added in v2.7.0

func (ah *AggregateModelWrapper) GroupID() string

func (*AggregateModelWrapper) Handle added in v2.7.0

func (ah *AggregateModelWrapper) Handle(ctx context.Context, iter eventstore.Iter) error

func (*AggregateModelWrapper) HandleCommand added in v2.7.0

func (ah *AggregateModelWrapper) HandleCommand(ctx context.Context, cmd Command, newVersion uint64) ([]eventstore.Event, error)

func (*AggregateModelWrapper) TakeSnapshot added in v2.7.0

func (ah *AggregateModelWrapper) TakeSnapshot(newVersion uint64) (eventstore.Event, bool)

type Command

type Command = interface{}

Command user defined command that will handled in AggregateModel.HandleCommand

type FactoryModelFunc

type FactoryModelFunc = func(ctx context.Context, groupID, aggregateID string) (AggregateModel, error)

FactoryModelFunc creates model for aggregate

type RetryFunc

type RetryFunc func() (when time.Time, err error)

RetryFunc defines policy to repeat HandleCommand on concurrency exception.

func NewDefaultRetryFunc

func NewDefaultRetryFunc(limit int) RetryFunc

NewDefaultRetryFunc default retry function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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