Skip to main content

DurabilityMode

Enum DurabilityMode 

Source
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

Source

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.

Source

pub fn as_str(self) -> &'static str

CLI / log-friendly name. Matches the clap::ValueEnum kebab-cased spelling.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> DurabilityMode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DurabilityMode

Source§

impl Debug for DurabilityMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DurabilityMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DurabilityMode

Source§

impl PartialEq for DurabilityMode

Source§

fn eq(&self, other: &DurabilityMode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DurabilityMode

Source§

impl ValueEnum for DurabilityMode

Source§

fn value_variants<'a>() -> &'a [Self]

All possible argument values, in display order.
Source§

fn to_possible_value<'a>(&self) -> Option<PossibleValue>

The canonical argument value. Read more
Source§

fn from_str(input: &str, ignore_case: bool) -> Result<Self, String>

Parse an argument into Self.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OptionalSend for T
where T: Send + ?Sized,

Source§

impl<T> OptionalSync for T
where T: Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more