aggregate

package
v2.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 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

func NewAggrModel added in v2.2.4

func NewAggrModel(ctx context.Context, groupID, aggregateID string, store eventstore.EventStore, logDebugfFunc eventstore.LogDebugfFunc, model AggregateModel) (*aggrModel, error)

Types

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, numEventsInSnapshot int, store eventstore.EventStore, factoryModel FactoryModelFunc, LogDebugfFunc eventstore.LogDebugfFunc) (*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) (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) HandleCommandWithAggrModel added in v2.2.4

func (a *Aggregate) HandleCommandWithAggrModel(ctx context.Context, cmd Command, amodel *aggrModel) (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 Command

type Command = interface{}

Command user defined command that will handled in AggregateModel.HandleCommand

type FactoryModelFunc

type FactoryModelFunc = func(ctx context.Context) (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