pub struct ConnectionHealthChecker {
pub connections: HashMap<u64, ConnectionRecord>,
pub config: HealthCheckerConfig,
pub next_conn_id: u64,
}Expand description
Tracks and evaluates the health of a set of TCP/QUIC connections.
Call open_connection to begin
monitoring a connection, feed events via
record_event, and query health
through alive_connections,
dead_connections, or
stats.
Fields§
§connections: HashMap<u64, ConnectionRecord>All tracked connections, keyed by connection ID.
config: HealthCheckerConfigConfiguration governing threshold behaviour.
next_conn_id: u64Monotonically increasing counter used to assign connection IDs.
Implementations§
Source§impl ConnectionHealthChecker
impl ConnectionHealthChecker
Sourcepub fn new(config: HealthCheckerConfig) -> Self
pub fn new(config: HealthCheckerConfig) -> Self
Create a new checker with the supplied configuration.
Sourcepub fn open_connection(&mut self, peer_id: String) -> u64
pub fn open_connection(&mut self, peer_id: String) -> u64
Begin monitoring a connection to peer_id.
Returns the stable connection ID that must be supplied to subsequent calls.
Sourcepub fn record_event(&mut self, conn_id: u64, event: ConnectionEvent)
pub fn record_event(&mut self, conn_id: u64, event: ConnectionEvent)
Feed an event into the connection record identified by conn_id.
Unknown conn_id values are silently ignored so that callers do not
need to guard against race conditions between close and event delivery.
Sourcepub fn close_connection(&mut self, conn_id: u64) -> bool
pub fn close_connection(&mut self, conn_id: u64) -> bool
Remove a connection from tracking.
Returns true when the connection was present and has been removed,
false when no record with conn_id existed.
Sourcepub fn alive_connections(&self) -> Vec<&ConnectionRecord>
pub fn alive_connections(&self) -> Vec<&ConnectionRecord>
Returns references to all connections that are not in the Dead
state, in unspecified order.
Sourcepub fn dead_connections(&self) -> Vec<&ConnectionRecord>
pub fn dead_connections(&self) -> Vec<&ConnectionRecord>
Returns references to all connections that are in the Dead
state, in unspecified order.
Auto Trait Implementations§
impl Freeze for ConnectionHealthChecker
impl RefUnwindSafe for ConnectionHealthChecker
impl Send for ConnectionHealthChecker
impl Sync for ConnectionHealthChecker
impl Unpin for ConnectionHealthChecker
impl UnsafeUnpin for ConnectionHealthChecker
impl UnwindSafe for ConnectionHealthChecker
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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