inmem

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package inmem provides an in-memory implementation of memory.Store for testing and local development. Data is stored in process memory and is lost when the process exits. Production deployments should use a durable backend such as features/memory/mongo (MongoDB-backed implementation).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements memory.Store using an in-process map keyed by agent ID and run ID. It is thread-safe and suitable for tests and local development. Data is not persisted across restarts.

The store maintains a two-level map: agentID -> runID -> events, allowing efficient isolation between agents and runs. All operations defensively copy data to prevent external mutation.

func New

func New() *Store

New returns a new in-memory store instance with no events. The store is ready to use immediately and requires no initialization or cleanup.

func (*Store) AppendEvents

func (s *Store) AppendEvents(_ context.Context, agentID, runID string, events ...memory.Event) error

AppendEvents appends the provided events to the run history. Events are copied defensively to ensure callers cannot mutate the internal store. If events is empty, this is a no-op.

Thread-safe: concurrent writes acquire an exclusive lock and serialize. Writes to different runs do not block each other but are still serialized within this implementation.

func (*Store) LoadRun

func (s *Store) LoadRun(_ context.Context, agentID, runID string) (memory.Snapshot, error)

LoadRun retrieves the snapshot for the given agent and run. Returns an empty snapshot (not an error) if the run doesn't exist, allowing callers to treat absence as empty history. The returned snapshot contains a defensive copy of events to prevent external mutation.

Thread-safe: concurrent reads are allowed and do not block each other.

func (*Store) Reset

func (s *Store) Reset()

Reset clears all stored events across all agents and runs. Primarily useful in tests to reset state between test cases. Not typically needed in production since inmem stores are ephemeral.

Jump to

Keyboard shortcuts

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