pub enum DurabilityMode {
Local,
Replicated,
Hybrid,
DurablyReplicated,
}Expand description
clap::ValueEnum derives --durability-mode <local|replicated|hybrid|durably-replicated>.
Variants§
Local
persisted>=1. Single-node durability — the primary’s
PLP-backed NVMe write is the only confirmation needed.
Required when running with --standalone; appropriate for
dev/staging deployments without a replica.
Replicated
in_memory>=2. RAM-quorum durability — a second node holds the
event in memory before the client ack; every disk write trails
asynchronously off the ack path (the journal still fsyncs every
batch, it just no longer gates responses). Survives any single
node failure via failover; loses only the un-fsynced tail on a
simultaneous whole-cluster power loss. For deployments where
fsync is slow (cloud block storage) or where that bounded RPO
is an acceptable trade for the lowest ack latency. Fails closed
when no replica is connected.
Hybrid
persisted>=1 && in_memory>=2. One durable copy on the
primary’s disk plus an in-memory ack from a second node.
Single-failure-safe with a brief RAM-only window (~80 µs on
PLP-backed NVMe) for the secondary copy. The default — typical
live trading deployments. Saves ~50–80 µs per fill vs
DurablyReplicated. Fails closed
when no replica is connected.
DurablyReplicated
persisted>=2. Two durable copies before client ack. Zero
RAM-only window; the gate stalls if no replica is currently
connected. Compliance-driven venues.
Implementations§
Source§impl DurabilityMode
impl DurabilityMode
Sourcepub fn to_policy(self) -> Policy
pub fn to_policy(self) -> Policy
Build the underlying Policy for this mode. Every variant’s
clause list is hand-constructed from in-range counts, so
Policy::new cannot fail — any regression would surface in
the unit tests below.
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
CLI / log-friendly name. Matches the clap::ValueEnum
kebab-cased spelling.
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parse the admin-channel / CLI wire spelling. Accepts the same
kebab-cased strings as_str emits so operators
only have to learn one vocabulary across --durability-mode
and the admin DURABILITY command.
Sourcepub fn as_u8(self) -> u8
pub fn as_u8(self) -> u8
Stable u8 discriminant. The response stage publishes the
operator-selected mode through an [AtomicU8] so it can detect
a runtime swap (via the admin DURABILITY command) with a
relaxed load on every gate iteration — cheaper than crossing a
Mutex or carrying a refcounted Arc<Policy> snapshot.
These values are a wire format, not just an in-process ABI:
the primary stamps this byte onto every StreamStart and
Heartbeat, and the replica decodes it with [from_u8] to
judge auto-promotion (see raft_promotion). So they must stay
stable across releases in two directions — the round-trip
from_u8(as_u8(x)) == Some(x) has to hold, and a value once
released can never be reassigned to a different mode, or a peer
on an older build would silently read the new mode as the old
one. Add new modes on the next free byte; never renumber.
A peer that does not know a byte gets None and refuses to
auto-promote on it — fail-closed, and the reason replicas must
be upgraded before a primary starts advertising a new mode.
Sourcepub fn from_u8(b: u8) -> Option<Self>
pub fn from_u8(b: u8) -> Option<Self>
Inverse of [as_u8]. Returns None for an unknown byte —
callers initialise the atomic from a valid mode and the admin
path only writes as_u8(parse(s)?), so an unknown byte
indicates memory corruption or a programmer bug. The response
stage logs and retains the prior mode in that case rather than
silently falling back.
Trait Implementations§
Source§impl Clone for DurabilityMode
impl Clone for DurabilityMode
Source§fn clone(&self) -> DurabilityMode
fn clone(&self) -> DurabilityMode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more