pub struct PartitionDetector { /* private fields */ }Expand description
Partition detector.
Tracks active partitions and detects healing when nodes reappear.
Implementations§
Source§impl PartitionDetector
impl PartitionDetector
Sourcepub fn with_healing_threshold(self, threshold: f32) -> Self
pub fn with_healing_threshold(self, threshold: f32) -> Self
Set the healing threshold (fraction of other_side that must reappear).
Sourcepub fn detect(
&mut self,
verdict: &CorrelationVerdict,
healthy_nodes: &[u64],
current_horizon: &ObservedHorizon,
) -> Option<u64>
pub fn detect( &mut self, verdict: &CorrelationVerdict, healthy_nodes: &[u64], current_horizon: &ObservedHorizon, ) -> Option<u64>
Attempt to detect a partition from a correlation verdict.
Only creates a partition record for MassFailure with SubnetFailure cause.
Returns the partition ID if created.
Sourcepub fn confirm(&mut self, partition_id: u64) -> bool
pub fn confirm(&mut self, partition_id: u64) -> bool
Confirm a partition (e.g., received gossip that other side is alive).
Sourcepub fn on_node_recovery(&mut self, node_id: u64)
pub fn on_node_recovery(&mut self, node_id: u64)
Record that a node has recovered (reappeared after failure).
If the node was in any partition’s other_side, transitions
the partition toward healing.
§Overlapping partitions
A single node id can appear in other_side of
multiple active partition records (e.g., a noisy detector
classified one physical outage into two records). This
function intentionally walks all matching records and
updates each independently — each record is the source of
truth for its own healing state.
Downstream consumers that fire side-effecting healing
actions per partition (replica rebalance, alert dispatch)
must be idempotent over (partition_id, recovered_node)
pairs, otherwise overlapping records will double-count
one physical recovery. The detector layer is the place to
prevent overlaps; this layer is just bookkeeping.
Sourcepub fn take_healed(&mut self) -> Vec<PartitionRecord>
pub fn take_healed(&mut self) -> Vec<PartitionRecord>
Take all partitions that have healed (drains them from active list).
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of active partitions.
Sourcepub fn get(&self, partition_id: u64) -> Option<&PartitionRecord>
pub fn get(&self, partition_id: u64) -> Option<&PartitionRecord>
Get an active partition by ID.