aggregate

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package aggregate provides an adaptor that exposes Dogma aggregate message handlers as Verity handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor

type Adaptor struct {
	// Identity is the handler's identity.
	Identity *envelopespec.Identity

	// Handler is the aggregate message handler that implements the
	// application-specific message handling logic.
	Handler dogma.AggregateMessageHandler

	// Loader is used to load aggregate instances into memory.
	Loader *Loader

	// Cache is an in-memory cache of aggregate instances.
	Cache cache.Cache

	// Packer is used to create new parcels for events recorded by the
	// handler.
	Packer *parcel.Packer

	// LoadTimeout is the timeout duration allowed while loading aggregate
	// state.
	LoadTimeout time.Duration

	// Logger is the target for log messages produced within the handler.
	// If it is nil, logging.DefaultLogger is used.
	Logger logging.Logger
}

Adaptor exposes a dogma.AggregateMessageHandler as a handler.Handler.

func (*Adaptor) HandleMessage

func (a *Adaptor) HandleMessage(
	ctx context.Context,
	w handler.UnitOfWork,
	p parcel.Parcel,
) (err error)

HandleMessage handles the message in p.

type Instance

type Instance struct {
	persistence.AggregateMetaData
	Root dogma.AggregateRoot
}

Instance is an in-memory representation of the aggregate instance, as stored in the cache.

type Loader

type Loader struct {
	// AggregateRepository is the repository used to load an aggregate instance's
	// revisions and snapshots.
	AggregateRepository persistence.AggregateRepository

	// EventRepository is the repository used to load an aggregate instance's
	// historical events.
	EventRepository persistence.EventRepository

	// Marshaler is used to marshal/unmarshal aggregate snapshots and historical
	// events,
	Marshaler marshaler.Marshaler
}

Loader loads aggregate instances from their historical events.

func (*Loader) Load

func (l *Loader) Load(
	ctx context.Context,
	hk, id string,
	base dogma.AggregateRoot,
) (*Instance, error)

Load loads the aggregate instance with the given ID.

Jump to

Keyboard shortcuts

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