pub struct PartitionDetector { /* private fields */ }Expand description
Partition detector
Implementations§
Source§impl PartitionDetector
impl PartitionDetector
pub fn new(config: PartitionConfig) -> Self
Sourcepub fn update_last_seen(&self, node_name: &str)
pub fn update_last_seen(&self, node_name: &str)
Update last seen time for a node
Sourcepub fn detect_partition(
&self,
cluster_state: &BTreeMap<String, NodeState>,
) -> PartitionState
pub fn detect_partition( &self, cluster_state: &BTreeMap<String, NodeState>, ) -> PartitionState
Detect partition based on current cluster state
Sourcepub fn current_state(&self) -> PartitionState
pub fn current_state(&self) -> PartitionState
Get current partition state
Sourcepub fn has_quorum(&self, reachable_count: usize) -> bool
pub fn has_quorum(&self, reachable_count: usize) -> bool
Check if we have quorum
Sourcepub fn get_unreachable_nodes(
&self,
cluster_state: &BTreeMap<String, NodeState>,
) -> Vec<String>
pub fn get_unreachable_nodes( &self, cluster_state: &BTreeMap<String, NodeState>, ) -> Vec<String>
Get unreachable nodes
Sourcepub fn should_serve(&self) -> bool
pub fn should_serve(&self) -> bool
Check if we should continue serving (have quorum)
Trait Implementations§
Source§impl Debug for PartitionDetector
impl Debug for 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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request