store

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package store is the Isopace persistence layer: a small collection/key/value Store interface for the durable records an operational deployment keeps — RBAC policy, configuration snapshots, audit summaries — kept deliberately narrow so it maps onto many backends.

MemStore is the in-process backend. A SQL-backed store is a drop-in adapter over the standard library's database/sql (the driver is the deployment's blank-import choice, so the core takes on no driver dependency); the durable space.Store is the queue analogue for store-and-forward. The PutJSON and GetJSON helpers marshal typed records over any Store.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("store: not found")

ErrNotFound is returned by Get for a missing collection/key.

Functions

func GetJSON

func GetJSON[T any](ctx context.Context, s Store, collection, key string) (T, error)

GetJSON loads collection/key and unmarshals it into a T.

func PutJSON

func PutJSON[T any](ctx context.Context, s Store, collection, key string, v T) error

PutJSON marshals v as JSON and stores it at collection/key.

Types

type MemStore

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

MemStore is the in-process Store backend: a map of collections to key/value maps. Values are copied on Put and Get so a caller cannot mutate stored data through a returned slice.

func NewMemStore

func NewMemStore() *MemStore

NewMemStore returns an empty in-memory store.

func (*MemStore) Close

func (m *MemStore) Close() error

Close releases the store (a no-op for MemStore).

func (*MemStore) Delete

func (m *MemStore) Delete(_ context.Context, collection, key string) error

Delete removes collection/key. Deleting a missing key is not an error.

func (*MemStore) Get

func (m *MemStore) Get(_ context.Context, collection, key string) ([]byte, error)

Get returns a copy of the value at collection/key, or ErrNotFound.

func (*MemStore) List

func (m *MemStore) List(_ context.Context, collection string) ([]string, error)

List returns the keys in a collection, sorted. An unknown collection yields an empty slice (not an error).

func (*MemStore) Put

func (m *MemStore) Put(_ context.Context, collection, key string, value []byte) error

Put stores a copy of value at collection/key.

type Store

type Store interface {
	Get(ctx context.Context, collection, key string) ([]byte, error)
	Put(ctx context.Context, collection, key string, value []byte) error
	Delete(ctx context.Context, collection, key string) error
	List(ctx context.Context, collection string) ([]string, error)
	Close() error
}

Store is a collection/key/value persistence interface. A collection is a namespace (like a table); within it, keys map to opaque byte values. Implementations must be safe for concurrent use.

Jump to

Keyboard shortcuts

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