memory

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package memory is an in-memory Store, for tests and for the M6 vertical slice.

An adapter, so the constructs the domain forbids are legitimate here: `sync`, `context`, mutable state. That asymmetry is the architecture working — a purity rule that fired in this package would be a rule nobody kept.

It is deliberately not a general-purpose store. There is no query language, no index and no persistence, because the slice exists to prove the boundaries hold, not to be a database.

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 keeps streams in memory.

func NewStore

func NewStore() *Store

NewStore creates an empty store.

func (*Store) Append added in v0.4.0

func (s *Store) Append(
	_ context.Context,
	name string,
	expect app.Expectation,
	envelope domain.Envelope,
	kind domain.Kind,
	payload domain.Payload,
) (domain.Ref, error)

Append records one fact against the authoritative stream and returns the ref the store assigned (ADR-0034).

This is the whole point of the port change. The sequence comes from the length of the stream *held here*, under the lock, rather than from whatever length a caller happened to read — so two concurrent appends receive consecutive refs instead of the same one.

The stream is created on first append: a stream is the facts in it, and there is nothing to declare in advance.

func (*Store) Load

func (s *Store) Load(_ context.Context, name string) (domain.Stream, error)

Load returns a stream, or app.ErrStreamNotFound.

func (*Store) Serialise added in v0.8.0

func (s *Store) Serialise(
	ctx context.Context,
	name string,
	fn func(context.Context, app.Store) error,
) error

Serialise runs fn holding the write region for `name` (ADR-0041).

For an in-memory store, "every writer holding this store" is every writer that shares the process, because a second process cannot reach this map. That makes the guarantee complete here rather than partial — the same sentence that is a limitation for a durable adapter.

Jump to

Keyboard shortcuts

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