Skip to main content

ReplicationConfig

Struct ReplicationConfig 

Source
pub struct ReplicationConfig {
    pub factor: u8,
    pub placement: PlacementStrategy,
    pub heartbeat_ms: u64,
    pub leader_pinned: Option<NodeId>,
    pub on_under_capacity: UnderCapacity,
    pub replication_budget_fraction: f32,
    pub default_bandwidth_class: BandwidthClass,
    pub background_fraction: f32,
}
Expand description

Per-channel replication opt-in. The default-when-set ReplicationConfig::new gives sensible values (factor 3, 500 ms heartbeat, standard placement, withdraw-under-capacity, 0.5 NIC peak budget); the with_* builders adjust individual fields.

validate() runs the full set of invariants pinned at module top — callers should invoke it before committing the config to a Redex so a malformed config can’t leak into the coordinator’s hot loop.

Fields§

§factor: u8

Replication factor — number of replicas (including the leader) maintained. Must satisfy REPLICATION_FACTOR_MIN <= factor <= REPLICATION_FACTOR_MAX. Default REPLICATION_FACTOR_DEFAULT.

§placement: PlacementStrategy

How replicas are chosen when first instantiated and on roster change. Default PlacementStrategy::Standard.

§heartbeat_ms: u64

Heartbeat interval between leader and replicas, in milliseconds. Must satisfy heartbeat_ms >= HEARTBEAT_MS_MIN. Default HEARTBEAT_MS_DEFAULT.

§leader_pinned: Option<NodeId>

Optional override pinning the leader to a specific node. None = leader is the channel’s natural publisher (the ChannelPublisher home). When Some(node), the override applies on every leader election; the deterministic nearest-RTT election picks node whenever it’s healthy.

§on_under_capacity: UnderCapacity

Behavior when a replica falls below the channel’s retention requirement due to local disk pressure. Default UnderCapacity::Withdraw.

§replication_budget_fraction: f32

Bandwidth budget for replication-sync I/O, as a fraction of measured NIC peak. Must lie in (0.0, 1.0] and be finite. Default REPLICATION_BUDGET_FRACTION_DEFAULT.

§default_bandwidth_class: BandwidthClass

v0.3 Phase D2: per-channel default BandwidthClass the runtime stamps on every emitted SyncRequest unless the caller explicitly overrides it. Receivers honor the per-request value in preference to this default. Default BandwidthClass::Foreground.

§background_fraction: f32

v0.3 Phase D2: admission-gate parameter — the fraction of the bandwidth bucket reserved against Background requests. A Background request is admitted only when available >= (1 - background_fraction) * capacity. Operators tune per channel: hot channels set this low (tight Background bound, more Foreground headroom); archival channels set it high (give Background more room). Must lie in [0.0, 1.0) and be finite (1.0 would deny every Background request unconditionally and is rejected; the v0.3 Phase D4 anti-starvation hatch one- shot bypasses the gate after 60 s starve regardless of the configured value). Default BACKGROUND_FRACTION_DEFAULT.

Implementations§

Source§

impl ReplicationConfig

Source

pub fn new() -> Self

Construct a ReplicationConfig with all defaults — factor 3, 500 ms heartbeat, standard placement, withdraw-under- capacity, 0.5 NIC peak budget, leader = natural publisher.

Source

pub fn with_factor(self, factor: u8) -> Self

Set the replication factor. Validate via Self::validate before committing the config to a Redex.

Source

pub fn with_placement(self, placement: PlacementStrategy) -> Self

Set the placement strategy.

Source

pub fn with_heartbeat_ms(self, heartbeat_ms: u64) -> Self

Set the heartbeat cadence in milliseconds.

Source

pub fn with_leader_pinned(self, leader: Option<NodeId>) -> Self

Pin the leader to a specific NodeId. Pass None to fall back to “leader = natural publisher.”

Source

pub fn with_on_under_capacity(self, on_under_capacity: UnderCapacity) -> Self

Set the under-capacity policy.

Source

pub fn with_replication_budget_fraction(self, fraction: f32) -> Self

Set the replication-sync I/O budget as a fraction of measured NIC peak.

Source

pub fn with_default_bandwidth_class(self, class: BandwidthClass) -> Self

Set the per-channel default BandwidthClass the runtime stamps on emitted SyncRequest frames. v0.3 Phase D2 — defaults to Foreground.

Source

pub fn with_background_fraction(self, fraction: f32) -> Self

Set the per-channel background_fraction — the share of the bandwidth bucket reserved against Background admission. Must lie in [0.0, 1.0) and be finite (1.0 is rejected as it would deny every Background request unconditionally). Default BACKGROUND_FRACTION_DEFAULT (0.3).

Source

pub fn effective_factor(&self) -> u8

Effective replica count — placement may override factor: PlacementStrategy::Pinned pins the count to the length of its Vec<NodeId> regardless of the configured factor (the operator’s explicit list wins over the numeric hint). All other strategies honor factor.

Source

pub fn validate(&self) -> Result<(), ReplicationConfigError>

Run every documented invariant. Returns Ok(()) when the config is safe to commit; otherwise a typed ReplicationConfigError naming the first violation. Pin in tests; surface to operators on Redex::open_file.

Trait Implementations§

Source§

impl Clone for ReplicationConfig

Source§

fn clone(&self) -> ReplicationConfig

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 Debug for ReplicationConfig

Source§

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

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

impl Default for ReplicationConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ReplicationConfig

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ReplicationConfig

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, 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> 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, 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<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