aggregate

package
v0.0.0-...-4309e98 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agg

type Agg struct {
	Events []Event

	Version string
	// contains filtered or unexported fields
}

func (*Agg) CurrentState

func (agg *Agg) CurrentState() ([]byte, string)

func (*Agg) History

func (agg *Agg) History() []Event

func (*Agg) WithChange

func (agg *Agg) WithChange(state []byte)

type AggBatch

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

func (*AggBatch) History

func (agg *AggBatch) History(id string) []Event

func (*AggBatch) State

func (agg *AggBatch) State(id string) ([]byte, string)

func (*AggBatch) WithChange

func (agg *AggBatch) WithChange(id string, state any) error

type Event

type Event struct {
	State         []byte    `json:"state"`
	Uncommitted   bool      `json:"uncommitted"`
	TransactionID *string   `json:"transactionId"`
	Deleted       bool      `json:"deleted"`
	CreatedAt     time.Time `json:"createdAt"`
}

type Service

type Service interface {
	// GetBatch returns aggregates and a function that persist aggregate changes
	GetBatch(ctx context.Context, ids []string) (aggs *AggBatch, persist func() error, err error)
}

func NewService

func NewService(tSvc transaction.Service, events keyvalue.Versioned[State]) Service

type State

type State struct {
	Events []Event `json:"events"`
	Dirty  bool    `json:"dirty"`
}

Jump to

Keyboard shortcuts

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