memory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package memory provides a bounded process-local audit sink for tests and development. It is not durable and must not be used as a compliance store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxRecords      int
	MaxBytes        int
	MaxBatchRecords int
}

Config declares all process-local capacity limits. Its zero value is invalid so tests cannot accidentally create an unbounded store.

type Store

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

Store is a bounded concurrency-safe in-memory sink. Its context-aware gate owns records, insertion order, and the byte counter; no caller callback runs while the gate is held.

func New

func New(config Config) (*Store, error)

New creates an empty bounded store.

func (*Store) Append

func (store *Store) Append(ctx context.Context, record audit.Record) (audit.AppendResult, error)

Append stores one record or reports an idempotent duplicate. Capacity and duplicate conflicts are confirmed rejections.

func (*Store) AppendBatch

func (store *Store) AppendBatch(ctx context.Context, records []audit.Record) (audit.BatchResult, error)

AppendBatch validates and commits the entire batch atomically in input order. A returned error means no member of that call was added.

func (*Store) Export

func (store *Store) Export(ctx context.Context, query audit.Query, consume func(audit.Record) error) error

Export invokes consume outside the store gate for at most Query.Limit records in stable query order.

func (*Store) Query

func (store *Store) Query(ctx context.Context, query audit.Query) (audit.Page, error)

Query returns records ordered by recording time then record ID. The cursor is exclusive and stable across insertion order.

Jump to

Keyboard shortcuts

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