pub struct PartitionDetector { /* private fields */ }Expand description
Partition detection coordinator
Tracks heartbeat state for all peers and detects network partitions.
Implementations§
Source§impl PartitionDetector
impl PartitionDetector
Sourcepub fn new() -> PartitionDetector
pub fn new() -> PartitionDetector
Create a new partition detector with default config
Sourcepub fn with_config(config: PartitionConfig) -> PartitionDetector
pub fn with_config(config: PartitionConfig) -> PartitionDetector
Create a new partition detector with custom config
Sourcepub fn config(&self) -> &PartitionConfig
pub fn config(&self) -> &PartitionConfig
Get partition config
Sourcepub fn register_peer(&self, peer_id: PublicKey)
pub fn register_peer(&self, peer_id: PublicKey)
Register a new peer for heartbeat tracking
Sourcepub fn unregister_peer(&self, peer_id: &PublicKey)
pub fn unregister_peer(&self, peer_id: &PublicKey)
Remove a peer from heartbeat tracking
Sourcepub fn record_heartbeat_success(
&self,
peer_id: &PublicKey,
) -> Option<PartitionEvent>
pub fn record_heartbeat_success( &self, peer_id: &PublicKey, ) -> Option<PartitionEvent>
Record a successful heartbeat for a peer
Returns an optional partition event if a state transition occurred
Sourcepub fn record_heartbeat_failure(
&self,
peer_id: &PublicKey,
) -> Option<PartitionEvent>
pub fn record_heartbeat_failure( &self, peer_id: &PublicKey, ) -> Option<PartitionEvent>
Record a heartbeat failure for a peer
Returns an optional partition event if partition was detected or failure occurred
Sourcepub fn get_peer_state(&self, peer_id: &PublicKey) -> Option<PeerPartitionState>
pub fn get_peer_state(&self, peer_id: &PublicKey) -> Option<PeerPartitionState>
Get the partition state for a peer
Sourcepub fn get_peer_heartbeat(&self, peer_id: &PublicKey) -> Option<PeerHeartbeat>
pub fn get_peer_heartbeat(&self, peer_id: &PublicKey) -> Option<PeerHeartbeat>
Get heartbeat info for a peer
Sourcepub fn get_partitioned_peers(&self) -> Vec<PublicKey>
pub fn get_partitioned_peers(&self) -> Vec<PublicKey>
Get all partitioned peers
Sourcepub fn check_timeouts(&self) -> Vec<PartitionEvent>
pub fn check_timeouts(&self) -> Vec<PartitionEvent>
Check all peers for timeout-based partition detection
Returns a list of partition events for newly partitioned peers
Sourcepub fn peer_count(&self) -> usize
pub fn peer_count(&self) -> usize
Get number of tracked peers
Trait Implementations§
Source§impl Default for PartitionDetector
impl Default for PartitionDetector
Source§fn default() -> PartitionDetector
fn default() -> PartitionDetector
Auto Trait Implementations§
impl Freeze for PartitionDetector
impl RefUnwindSafe for PartitionDetector
impl Send for PartitionDetector
impl Sync for PartitionDetector
impl Unpin for PartitionDetector
impl UnsafeUnpin for PartitionDetector
impl UnwindSafe for PartitionDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more