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: u8Replication factor — number of replicas (including the leader)
maintained. Must satisfy
REPLICATION_FACTOR_MIN <= factor <= REPLICATION_FACTOR_MAX.
Default REPLICATION_FACTOR_DEFAULT.
placement: PlacementStrategyHow replicas are chosen when first instantiated and on roster
change. Default PlacementStrategy::Standard.
heartbeat_ms: u64Heartbeat 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: UnderCapacityBehavior when a replica falls below the channel’s retention
requirement due to local disk pressure. Default
UnderCapacity::Withdraw.
replication_budget_fraction: f32Bandwidth 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: BandwidthClassv0.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: f32v0.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
impl ReplicationConfig
Sourcepub fn new() -> Self
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.
Sourcepub fn with_factor(self, factor: u8) -> Self
pub fn with_factor(self, factor: u8) -> Self
Set the replication factor. Validate via Self::validate
before committing the config to a Redex.
Sourcepub fn with_placement(self, placement: PlacementStrategy) -> Self
pub fn with_placement(self, placement: PlacementStrategy) -> Self
Set the placement strategy.
Sourcepub fn with_heartbeat_ms(self, heartbeat_ms: u64) -> Self
pub fn with_heartbeat_ms(self, heartbeat_ms: u64) -> Self
Set the heartbeat cadence in milliseconds.
Sourcepub fn with_leader_pinned(self, leader: Option<NodeId>) -> Self
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.”
Sourcepub fn with_on_under_capacity(self, on_under_capacity: UnderCapacity) -> Self
pub fn with_on_under_capacity(self, on_under_capacity: UnderCapacity) -> Self
Set the under-capacity policy.
Sourcepub fn with_replication_budget_fraction(self, fraction: f32) -> Self
pub fn with_replication_budget_fraction(self, fraction: f32) -> Self
Set the replication-sync I/O budget as a fraction of measured NIC peak.
Sourcepub fn with_default_bandwidth_class(self, class: BandwidthClass) -> Self
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.
Sourcepub fn with_background_fraction(self, fraction: f32) -> Self
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).
Sourcepub fn effective_factor(&self) -> u8
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.
Sourcepub fn validate(&self) -> Result<(), ReplicationConfigError>
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
impl Clone for ReplicationConfig
Source§fn clone(&self) -> ReplicationConfig
fn clone(&self) -> ReplicationConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReplicationConfig
impl Debug for ReplicationConfig
Source§impl Default for ReplicationConfig
impl Default for ReplicationConfig
Source§impl PartialEq for ReplicationConfig
impl PartialEq for ReplicationConfig
Source§fn eq(&self, other: &ReplicationConfig) -> bool
fn eq(&self, other: &ReplicationConfig) -> bool
self and other values to be equal, and is used by ==.