memory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package memory provides an in-memory EventStore implementation. It is intended for tests and development only — data is lost on process restart. It fully satisfies the storetest contract suite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactStore

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

ArtifactStore is an in-memory implementation of runtime.ArtifactStore. Keys are formatted as "<loopID>/<seq>/<counter>" to guarantee uniqueness. This implementation is goroutine-safe.

func NewArtifactStore

func NewArtifactStore() *ArtifactStore

NewArtifactStore creates an empty in-memory ArtifactStore.

func (*ArtifactStore) Get

func (s *ArtifactStore) Get(_ context.Context, key string) ([]byte, error)

Get retrieves a previously stored artifact by key.

func (*ArtifactStore) Put

func (s *ArtifactStore) Put(_ context.Context, loopID event.LoopID, seq uint64, data []byte) (string, error)

Put stores data and returns a unique key of the form "<loopID>/<seq>/<counter>".

type Store

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

Store is the in-memory EventStore. Thread-safe.

func New

func New() *Store

New creates a new empty in-memory Store.

func (*Store) Append

func (s *Store) Append(_ context.Context, id event.LoopID, expectedLastSeq uint64, evs []event.Envelope) error

Append appends evs to the event log for loop id. expectedLastSeq must match the actual last seq (0 if no events exist yet). Returns runtime.ErrConflict on mismatch.

func (*Store) LatestSnapshot

func (s *Store) LatestSnapshot(_ context.Context, id event.LoopID) (event.Snapshot, bool, error)

LatestSnapshot returns the snapshot with the highest Seq for the given loop.

func (*Store) List

List returns loop metadata matching the filter.

func (*Store) Load

func (s *Store) Load(_ context.Context, id event.LoopID, fromSeq uint64) iter.Seq2[event.Envelope, error]

Load returns an iterator over events for the given loop starting at fromSeq.

func (*Store) SaveSnapshot

func (s *Store) SaveSnapshot(_ context.Context, snap event.Snapshot) error

SaveSnapshot persists a snapshot.

Jump to

Keyboard shortcuts

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