Documentation
¶
Overview ¶
Package catalogstore provides durable generation-oriented catalog storage.
Index ¶
- func DecodeCatalogPayload(data []byte) (*catalogs.Catalog, error)
- func DecodeSourceObservationPayload(data []byte) (*catalogs.Catalog, error)
- func EncodeCatalogPayload(reader catalogs.Reader) ([]byte, error)
- type Filesystem
- type Generation
- type Memory
- type MemoryObjectBackend
- type Object
- type ObjectBackend
- type ObjectPutCondition
- type ObjectValue
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCatalogPayload ¶
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
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.
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 (*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.
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 ¶
ObjectPutCondition configures an atomic conditional object write.
type ObjectValue ¶
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.