pub struct FailoverController { /* private fields */ }Expand description
A higher-level node health monitor that combines heartbeat-timeout detection with explicit mark/recover operations.
Unlike FailoverCoordinator (which is tied to the Raft election
machinery), FailoverController is a self-contained monitor suitable for
use by the cluster topology dashboard, the alerting subsystem, or external
health-check drivers.
§Thread safety
All methods use internal locks; the struct is Send + Sync.
§Test injection
Tests may call set_last_seen to back-date the last
heartbeat timestamp for a node without actually waiting.
Implementations§
Source§impl FailoverController
impl FailoverController
Sourcepub fn new(heartbeat_timeout: Duration) -> Self
pub fn new(heartbeat_timeout: Duration) -> Self
Create a new controller.
heartbeat_timeout — how long a node can go without sending a
heartbeat before it is considered failed.
Sourcepub fn record_heartbeat(&self, node_id: NodeId)
pub fn record_heartbeat(&self, node_id: NodeId)
Record that a heartbeat was received from node_id.
If the node was previously marked as failed it is automatically recovered.
Sourcepub fn detect_failed_nodes(&self) -> Vec<NodeId> ⓘ
pub fn detect_failed_nodes(&self) -> Vec<NodeId> ⓘ
Check all known nodes; return the IDs of nodes that have not sent a heartbeat within the timeout window.
Nodes detected here are also added to the internal failed set (visible
via is_failed / failed_nodes).
Sourcepub fn mark_failed(&self, node_id: NodeId)
pub fn mark_failed(&self, node_id: NodeId)
Explicitly mark a node as failed (e.g. after Raft loss-of-quorum).
Sourcepub fn mark_recovered(&self, node_id: NodeId)
pub fn mark_recovered(&self, node_id: NodeId)
Mark a node as recovered.
This removes it from the failed set. Call
record_heartbeat as well to reset the
timeout clock.
Sourcepub fn is_failed(&self, node_id: NodeId) -> bool
pub fn is_failed(&self, node_id: NodeId) -> bool
Return true if node_id is currently considered failed.
Sourcepub fn failed_nodes(&self) -> Vec<NodeId> ⓘ
pub fn failed_nodes(&self) -> Vec<NodeId> ⓘ
Return all currently failed node IDs as a Vec.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FailoverController
impl !RefUnwindSafe for FailoverController
impl Send for FailoverController
impl Sync for FailoverController
impl Unpin for FailoverController
impl UnsafeUnpin for FailoverController
impl UnwindSafe for FailoverController
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.