Skip to main content

Crate slipstream

Crate slipstream 

Source
Expand description

Shared KV store abstraction for Beyond services.

This crate provides a backend-agnostic interface for key-value storage, with NATS JetStream as the primary implementation.

§Architecture

┌─────────────────────────────────────────────────────────────┐
│              KvReader │ KvWatcher │ KvWriter                │
│                 (core KV operations)                        │
├─────────────────────────────────────────────────────────────┤
│                        KvStore                              │
│            (named bucket with reader/watcher/writer)        │
├─────────────────────────────────────────────────────────────┤
│                       Connection                            │
│              (lifecycle, store factory, capabilities)       │
├─────────────────────────────────────────────────────────────┤
│                    NatsConnection                           │
│               (concrete implementation)                     │
└─────────────────────────────────────────────────────────────┘

Re-exports§

pub use snapshot::AppendLogSnapshot;
pub use snapshot::SnapshotStore;

Modules§

protocol
Protocol decision kernels — the load-bearing guards of the snapshot export/import protocol, extracted as pure functions so the PRODUCTION code and the exhaustive model checker (tests/model.rs) execute the same logic, not two hand-synchronized copies of it.
snapshot
Append-only snapshot log for KV state.

Structs§

ArtifactFile
One payload file in an ExportManifest.
BatchConfig
Batching policy for watch_applied.
ConnectionCapabilities
Capabilities a store connection may support.
ExportLease
Coordinates “at most one export per round” across every replica of a fold. See the module docs for the CAS + embedded-expiry mechanism.
ExportManifest
Manifest of an exported artifact: what is in it, which backend wrote it, and the cursor its payload is consistent with.
ExportRequest
A request, sent into a running watch_applied loop, to export the fold it owns (see SnapshotStore::export_to).
KvEntry
A single key-value entry with metadata.
LeaseGuard
Proof of a won round, returned by ExportLease::try_acquire.
LeaseRecord
The lease key’s value: who holds (or last held) the round, until when, and — after LeaseGuard::complete — what was exported.
NatsConnection
NATS JetStream KV connection.
NatsConnectionConfig
Configuration for NATS connection.
StoreConfig
Configuration for creating a store.
VersionToken
Opaque version token that abstracts store-specific versioning.
WatchCursor
Opaque position in a watch stream for resuming after disconnect.

Enums§

KvError
Error type for KV operations.
KvUpdate
Update event from a watch stream.
StorageType
Storage type for a store.
WatchScope
What to watch: every key, every key under a prefix, or the union of several prefixes.

Constants§

ARTIFACT_SCHEMA_VERSION
Version of the artifact layout itself (MANIFEST.json schema + data/ payload convention). Bumped only when the artifact shape changes; the payload format is governed separately by ExportManifest::backend_version.
MANIFEST_FILE
Manifest file name at the artifact root. Written last and fsynced, so its presence (after the atomic rename) means the artifact is complete.

Traits§

Connection
Store connection lifecycle and store factory.
KvReader
Core read-only KV operations - the minimal interface every store must implement.
KvStore
A named KV store (bucket/namespace/database).
KvTtl
TTL support - optional, for stores that support key expiration.
KvWatcher
Watch capability - optional, not all stores support real-time updates.
KvWriter
Write operations - optional, edge proxy is primarily read-only.

Functions§

nats_connect
Connect to NATS with various authentication methods.
watch_applied
Drive a watch with cursor-after-apply semantics.