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) │
└─────────────────────────────────────────────────────────────┘Modules§
- snapshot
- Append-only snapshot log for KV state.
Structs§
- Batch
Config - Batching policy for
watch_applied. - Connection
Capabilities - Capabilities a store connection may support.
- KvEntry
- A single key-value entry with metadata.
- Nats
Connection - NATS JetStream KV connection.
- Nats
Connection Config - Configuration for NATS connection.
- Store
Config - Configuration for creating a store.
- Version
Token - Opaque version token that abstracts store-specific versioning.
- Watch
Cursor - Opaque position in a watch stream for resuming after disconnect.
Enums§
- KvError
- Error type for KV operations.
- KvUpdate
- Update event from a watch stream.
- Storage
Type - Storage type for a store.
- Watch
Scope - What to watch: every key, or every key under a prefix.
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.