catalogstore

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package catalogstore provides durable generation-oriented catalog storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCatalogPayload

func DecodeCatalogPayload(data []byte) (*catalogs.Catalog, error)

DecodeCatalogPayload decodes the current catalog payload. A non-nil catalog together with *sourcepayload.QuarantineError is a partial diagnostic result and must not be activated as the manifest-bound generation.

func DecodeSourceObservationPayload added in v0.2.0

func DecodeSourceObservationPayload(data []byte) (*catalogs.Catalog, error)

DecodeSourceObservationPayload decodes a source candidate without requiring every provider record to have resolved canonical authorship. The returned catalog is suitable only for reconciliation; durable generation activation must use DecodeCatalogPayload.

func EncodeCatalogPayload

func EncodeCatalogPayload(reader catalogs.Reader) ([]byte, error)

EncodeCatalogPayload deterministically encodes a readable catalog.

Types

type Filesystem

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

Filesystem stores immutable generation directories and an atomically replaced current pointer beneath one root directory.

func NewFilesystem

func NewFilesystem(path string) (*Filesystem, error)

NewFilesystem creates a filesystem catalog store rooted at path.

func (*Filesystem) Commit

func (s *Filesystem) Commit(ctx context.Context, generation Generation, expectedGenerationID string) error

Commit writes an immutable generation before atomically replacing current.

func (*Filesystem) Current

func (s *Filesystem) Current(ctx context.Context) (Generation, error)

Current returns the currently active generation.

func (*Filesystem) Get

func (s *Filesystem) Get(ctx context.Context, id string) (Generation, error)

Get returns an immutable generation by ID.

func (*Filesystem) Root

func (s *Filesystem) Root() string

Root returns the configured filesystem root without creating it.

type Generation

type Generation struct {
	Manifest catalogs.GenerationManifest
	Payload  []byte
}

Generation is an immutable manifest and its exact catalog payload bytes.

func (Generation) Copy

func (g Generation) Copy() Generation

Copy returns a generation that does not share mutable slices with g.

func (Generation) Validate

func (g Generation) Validate() error

Validate verifies the manifest and its binding to the payload.

type Memory

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

Memory is an in-process reference implementation of Store.

func NewMemory

func NewMemory() *Memory

NewMemory creates an empty in-memory catalog store.

func (*Memory) Commit

func (s *Memory) Commit(ctx context.Context, generation Generation, expectedGenerationID string) error

Commit validates and atomically activates generation when current matches expectedGenerationID.

func (*Memory) Current

func (s *Memory) Current(ctx context.Context) (Generation, error)

Current returns the currently active generation.

func (*Memory) Get

func (s *Memory) Get(ctx context.Context, id string) (Generation, error)

Get returns an immutable generation by ID.

type MemoryObjectBackend

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

MemoryObjectBackend is a deterministic reference object backend.

func NewMemoryObjectBackend

func NewMemoryObjectBackend() *MemoryObjectBackend

NewMemoryObjectBackend creates an empty reference object backend.

func (*MemoryObjectBackend) Get

Get returns a defensive copy of key.

func (*MemoryObjectBackend) Put

func (b *MemoryObjectBackend) Put(ctx context.Context, key string, data []byte, condition ObjectPutCondition) (ObjectValue, error)

Put atomically writes key when condition matches.

type Object

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

Object stores immutable generations in an object namespace and promotes a versioned current pointer with a conditional write.

func NewObject

func NewObject(backend ObjectBackend, prefix string) (*Object, error)

NewObject creates an object-backed catalog store.

func (*Object) Commit

func (s *Object) Commit(ctx context.Context, generation Generation, expectedGenerationID string) error

Commit uploads immutable generation objects before conditionally promoting the current pointer.

func (*Object) Current

func (s *Object) Current(ctx context.Context) (Generation, error)

Current returns the currently active generation.

func (*Object) Get

func (s *Object) Get(ctx context.Context, id string) (Generation, error)

Get returns an immutable generation by ID.

type ObjectBackend

type ObjectBackend interface {
	Get(context.Context, string) (ObjectValue, error)
	Put(context.Context, string, []byte, ObjectPutCondition) (ObjectValue, error)
}

ObjectBackend is the minimum immutable-object and conditional-pointer API required by Object.

Version must be a non-empty opaque token that identifies the exact returned object version. Put must atomically honor IfAbsent or IfVersion and return a typed conflict when its condition does not hold. Production adapters must never weaken either condition to an unconditional last-writer-wins write. Cloud adapters should translate ETags or object generations to Version.

type ObjectPutCondition

type ObjectPutCondition struct {
	IfAbsent  bool
	IfVersion string
}

ObjectPutCondition configures an atomic conditional object write.

type ObjectValue

type ObjectValue struct {
	Data    []byte
	Version string
}

ObjectValue is one versioned object returned by an ObjectBackend.

type Store

type Store interface {
	Current(context.Context) (Generation, error)
	Get(context.Context, string) (Generation, error)
	Commit(context.Context, Generation, string) error
}

Store commits and reads immutable catalog generations.

Commit always performs compare-and-swap against expectedGenerationID. An empty expected ID means that no current generation may exist. Implementations must validate and persist the complete generation before changing Current. Repeating an already-successful identical commit is idempotent.

Starmap provides memory, filesystem, and conditional object-storage implementations. Embedding applications own and inject any database-backed implementation, including its driver, schema, migrations, credentials, connection pool, backups, and lifecycle.

Directories

Path Synopsis
Package s3 provides an S3-compatible implementation of catalogstore.ObjectBackend.
Package s3 provides an S3-compatible implementation of catalogstore.ObjectBackend.

Jump to

Keyboard shortcuts

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