pub struct NetDb { /* private fields */ }Expand description
Unified NetDB handle.
Bundles one or more CortEX adapters (tasks, memories, …) behind a
single handle. Construct via NetDb::builder.
Implementations§
Source§impl NetDb
impl NetDb
Sourcepub fn builder(redex: Redex) -> NetDbBuilder
pub fn builder(redex: Redex) -> NetDbBuilder
Start building a NetDB.
Sourcepub fn tasks(&self) -> &TasksAdapter
pub fn tasks(&self) -> &TasksAdapter
Access the tasks model. Panics if with_tasks() wasn’t
called on the builder. Use Self::try_tasks for a checked
accessor.
Sourcepub fn try_tasks(&self) -> Option<&TasksAdapter>
pub fn try_tasks(&self) -> Option<&TasksAdapter>
Checked tasks accessor. Returns None if tasks were not
included at build time.
Sourcepub fn memories(&self) -> &MemoriesAdapter
pub fn memories(&self) -> &MemoriesAdapter
Access the memories model. Panics if with_memories() wasn’t
called.
Sourcepub fn try_memories(&self) -> Option<&MemoriesAdapter>
pub fn try_memories(&self) -> Option<&MemoriesAdapter>
Checked memories accessor.
Sourcepub fn redex(&self) -> &Redex
pub fn redex(&self) -> &Redex
Borrow the underlying Redex manager. Useful for lifecycle
operations (close a specific channel, sweep retention, etc.).
Sourcepub fn close(&self) -> Result<(), NetDbError>
pub fn close(&self) -> Result<(), NetDbError>
Close every enabled adapter. The underlying Redex files
stay open on the manager — reopening via another NetDb
against the same Redex instance replays or snapshots them.
Idempotent.
Both closes are attempted regardless of failure and the
FIRST error is surfaced as the function’s return; the
SECOND error is logged at warn so a double-failure is
observable in tracing without conflating the typed
error surface. Pre-fix the second error was dropped
silently — operators investigating a close() failure
from the typed return would never see the second adapter’s
error. The dominant double-failure mode is “underlying
redex already closed,” which produces the same error
from both adapters and is uninteresting to disambiguate
in the typed return; the warn-log makes it observable
without adding a new error variant.
Sourcepub fn snapshot(&self) -> Result<NetDbSnapshot, NetDbError>
pub fn snapshot(&self) -> Result<NetDbSnapshot, NetDbError>
Capture a snapshot of every enabled model. Each model is snapshotted under its own state lock (consistent per-model); there is no cross-model consistency guarantee because each model is a separate RedEX file.
Cross-model ordering caveat. Tasks are snapshotted
first, then memories. An ingest that lands in both models
between the two calls is captured by the memories snapshot
but missed by the tasks snapshot — so the resulting
NetDbSnapshot can split a logical “write to both models”
across the two halves. A watcher snapshotting between
event deliveries needs to either (a) treat each model’s
last_seq as the authoritative ordering and reconcile
idempotently on restore, or (b) drain both models’
wait_for_seq(known_last) before calling snapshot() to
pin a deliberate cut-off. The lock order (tasks → memories)
is fixed so any future writer that takes both locks must
match this order to avoid deadlock.