Documentation
¶
Overview ¶
Package catalogstore provides durable generation-oriented catalog storage.
Index ¶
- func DecodeCatalogPayload(data []byte) (*catalogs.Catalog, error)
- func EncodeCatalogPayload(reader catalogs.Reader) ([]byte, error)
- type CatalogPayload
- type Filesystem
- type Generation
- type LegacyMigrationOptions
- type Memory
- type MemoryObjectBackend
- type Object
- type ObjectBackend
- type ObjectPutCondition
- type ObjectValue
- type SQL
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCatalogPayload ¶
DecodeCatalogPayload strictly decodes and publishes a schema-v1 catalog payload.
Types ¶
type CatalogPayload ¶
type CatalogPayload = catalogs.CatalogPayload
CatalogPayload is the canonical catalog schema-v1 payload.
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 MigrateLegacyDirectory ¶
func MigrateLegacyDirectory(ctx context.Context, path string, options LegacyMigrationOptions) (Generation, error)
MigrateLegacyDirectory reads the pre-generation multi-file YAML format and converts it into a validated schema-v1 generation without mutating the source.
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 LegacyMigrationOptions ¶
type LegacyMigrationOptions struct {
GenerationID string
SyncRunID string
ObservationID string
GeneratedAt time.Time
ValidatorVersion string
}
LegacyMigrationOptions supplies deterministic identity and time metadata that did not exist in the legacy multi-file YAML catalog format.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in-process reference implementation of 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.
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 ¶
func (b *MemoryObjectBackend) Get(ctx context.Context, key string) (ObjectValue, error)
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.
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. Cloud adapters should translate ETags or generations to Version and conditional writes to ObjectPutCondition.
type ObjectPutCondition ¶
ObjectPutCondition configures an atomic conditional object write.
type ObjectValue ¶
ObjectValue is one versioned object returned by an ObjectBackend.
type SQL ¶
type SQL struct {
// contains filtered or unexported fields
}
SQL stores generations transactionally through database/sql. The baseline queries use the common SQLite-style question-mark bind syntax; the supported production adapter is SQLite.
func (*SQL) Commit ¶
Commit transactionally persists and activates generation when the current ID matches expectedGenerationID.
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.