pub struct ConnectionHealthMonitor { /* private fields */ }Expand description
Monitors WebSocket connection health with periodic pings.
This can be used to detect stale connections that are not receiving any messages (including pings from the server).
Implementations§
Source§impl ConnectionHealthMonitor
impl ConnectionHealthMonitor
Sourcepub fn new(max_idle_duration: Duration) -> Self
pub fn new(max_idle_duration: Duration) -> Self
Create a new connection health monitor.
§Arguments
max_idle_duration- Maximum time without activity before considering unhealthy.
Sourcepub async fn record_activity(&self)
pub async fn record_activity(&self)
Record activity on the connection.
Sourcepub async fn is_healthy(&self) -> bool
pub async fn is_healthy(&self) -> bool
Check if the connection is healthy.
Sourcepub async fn time_since_last_activity(&self) -> Duration
pub async fn time_since_last_activity(&self) -> Duration
Get the time since last activity.
Sourcepub fn start_background_check(
self: Arc<Self>,
check_interval: Duration,
) -> JoinHandle<()>
pub fn start_background_check( self: Arc<Self>, check_interval: Duration, ) -> JoinHandle<()>
Start a background health check task that updates is_healthy periodically.
Auto Trait Implementations§
impl Freeze for ConnectionHealthMonitor
impl !RefUnwindSafe for ConnectionHealthMonitor
impl Send for ConnectionHealthMonitor
impl Sync for ConnectionHealthMonitor
impl Unpin for ConnectionHealthMonitor
impl !UnwindSafe for ConnectionHealthMonitor
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