memory

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed indicates the in-memory Backend has been closed
	ErrClosed = errors.New("memory backend is closed")
)

Functions

This section is empty.

Types

type Backend

type Backend struct {
	timebox.AlwaysReady
	// contains filtered or unexported fields
}

Backend keeps store state in memory for semantic tests

func Open

func Open(cfgs ...Config) *Backend

Open opens a new in-memory Backend

func (*Backend) Append

func (b *Backend) Append(reqs ...timebox.AppendRequest) error

Append appends every request's events if each expected sequence matches

func (*Backend) Archive

func (b *Backend) Archive(id timebox.AggregateID) error

Archive archives an aggregate and removes it from active storage

func (*Backend) Close

func (b *Backend) Close() error

Close closes the in-memory Backend

func (*Backend) ConsumeArchive

func (b *Backend) ConsumeArchive(
	ctx context.Context, h timebox.ArchiveHandler,
) error

ConsumeArchive blocks until one archive record is available or ctx is done

func (*Backend) GetAggregateStatus

func (b *Backend) GetAggregateStatus(
	id timebox.AggregateID,
) (string, error)

GetAggregateStatus gets the current status for an aggregate

func (*Backend) ListAggregates

func (b *Backend) ListAggregates(
	typ timebox.ID,
) ([]timebox.AggregateID, error)

ListAggregates lists aggregate IDs of the given type, or of every type when it is empty

func (*Backend) ListAggregatesByStatus

func (b *Backend) ListAggregatesByStatus(
	q timebox.StatusQuery,
) ([]timebox.StatusEntry, error)

ListAggregatesByStatus lists aggregates matching the query, ordered by status time

func (*Backend) ListAggregatesByTag

func (b *Backend) ListAggregatesByTag(
	tag string,
) ([]timebox.AggregateID, error)

ListAggregatesByTag lists aggregates for a tag

func (*Backend) LoadEvents

func (b *Backend) LoadEvents(
	req timebox.LoadEventsRequest,
) (*timebox.EventsResult, error)

LoadEvents loads events starting at fromSeq

func (*Backend) LoadSnapshot

func (b *Backend) LoadSnapshot(
	req timebox.LoadSnapshotRequest,
) (*timebox.SnapshotRecord, error)

LoadSnapshot loads the snapshot and trailing events for an aggregate

func (*Backend) NewStore

func (b *Backend) NewStore(cfgs ...timebox.Config) (*timebox.Store, error)

NewStore creates a Store using the current in-memory Backend

func (*Backend) SaveSnapshot

func (b *Backend) SaveSnapshot(req timebox.SnapshotRequest) error

SaveSnapshot saves a snapshot if the sequence is not older

type Config added in v0.2.0

type Config struct {
	Publisher timebox.Publisher
}

Config configures a memory Backend

Jump to

Keyboard shortcuts

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