Documentation
¶
Overview ¶
Package store is the metastore / database-layer port (ADR-0006): a generic, watchable, versioned record store over ADR-0003 v1alpha1.Object values.
The store SEMANTICS (resourceVersion minting, generation bumping, optimistic concurrency, in-process watch, filtering, at-rest encryption) live here ONCE, over a minimal key/value Engine seam. Engines (memory, badger) are thin and swappable; New wraps any Engine with these semantics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encryptor ¶
type Encryptor interface {
Encrypt(ctx context.Context, plaintext []byte) ([]byte, error)
Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error)
}
Encryptor is the at-rest encryption seam (Decision §7). P-P/F15 supplies the implementation (tink/envelope); the store stays generic — it encrypts opaque value bytes for the configured kinds. With no encryptor, values are stored as-is.
type Engine ¶
type Engine interface {
View(ctx context.Context, fn func(Txn) error) error
Update(ctx context.Context, fn func(Txn) error) error
Close() error
}
Engine is the minimal key/value seam the store is built on. memory + badger implement it.
Update is contractually only an ATOMIC WRITE-BATCH (all-or-nothing); the seam does NOT promise serializable, in-txn read-your-writes isolation, so the store must not rely on it. Cross-writer serialization (the resourceVersion compare-and-set) is the store wrapper's job (a write mutex), not the engine's — an engine may happen to be serializable (badger's txns are), but the store treats the seam conservatively.
View runs read-only operations. The seam does not guarantee a consistent point-in-time snapshot across multiple reads on every engine (the memory engine holds a read lock, so it is; not all engines must). Consequently List's collection resourceVersion is best-effort under concurrent writes; a caller needing a strict snapshot re-reads at the returned resourceVersion.
type List ¶
List is the result of a List call: the matching objects plus the collection resourceVersion (the store-wide revision at read time).
type ListOptions ¶
type ListOptions struct {
Namespace v1.NamespaceName
ResourceGroup v1.ResourceGroupName
Tags v1.Tags
}
ListOptions narrows a List by namespace, resource group, and tag subset.
type Option ¶
type Option func(*config) error
Option configures a Store at construction (functional options, ADR-0002).
type Store ¶
type Store interface {
Get(ctx context.Context, gvk v1.GroupVersionKind, ns v1.NamespaceName, name v1.ObjectName) (v1.Object, error)
List(ctx context.Context, gvk v1.GroupVersionKind, opts ListOptions) (List, error)
Create(ctx context.Context, obj v1.Object) (v1.Object, error) // stamps uid, generation=1, resourceVersion, creationTimestamp
Update(ctx context.Context, obj v1.Object) (v1.Object, error) // RV precondition; bumps generation iff spec changed
Delete(ctx context.Context, gvk v1.GroupVersionKind, ns v1.NamespaceName, name v1.ObjectName, rv string) error
Watch(ctx context.Context, gvk v1.GroupVersionKind, opts WatchOptions) (Watch, error)
Close() error
}
Store is the metastore port: generic CRUD + List + in-process Watch over v1alpha1.Object, keyed by (GroupVersionKind, NamespaceName, ObjectName). Every method is ctx-first; every error is an api/fault kind.
type Txn ¶
type Txn interface {
Get(bucket, key string) ([]byte, bool, error)
Put(bucket, key string, val []byte) error
Delete(bucket, key string) error
Scan(bucket string, fn func(key string, val []byte) error) error
}
Txn is the key/value surface within a View/Update. Keys are scoped by bucket.
type Watch ¶
type Watch interface {
ResultChan() <-chan Event
Stop()
}
Watch is an open change stream. Stop releases it (idempotent); ResultChan is closed when the watch ends (Stop, ctx cancellation, or a dropped slow watcher).
type WatchOptions ¶
type WatchOptions struct {
Namespace v1.NamespaceName
SinceResourceVersion string
}
WatchOptions narrows a Watch and optionally replays from a resourceVersion.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package badger is the pure-Go store.Engine (ADR-0065): a Badger v4 LSM at a local directory, superseding ADR-0006's slatedb/cgo engine and restoring funcd's pure-Go static binary.
|
Package badger is the pure-Go store.Engine (ADR-0065): a Badger v4 LSM at a local directory, superseding ADR-0006's slatedb/cgo engine and restoring funcd's pure-Go static binary. |
|
Package memory is the pure-Go, cgo-free store.Engine: a process-local map guarded by a RWMutex.
|
Package memory is the pure-Go, cgo-free store.Engine: a process-local map guarded by a RWMutex. |
|
Package storecontract is the shared conformance suite for the store port (ADR-0006).
|
Package storecontract is the shared conformance suite for the store port (ADR-0006). |