Skip to main content

Mountain/IPC/Enhanced/ConnectionPool/
HealthChecker.rs

1
2//! Per-connection health-probe helper used by
3//! `Pool::Struct::start_health_monitoring`. Currently runs a
4//! simulated 10ms ping; real implementations would send a
5//! protocol-level keepalive.
6
7use std::time::{Duration, Instant};
8
9use crate::IPC::Enhanced::ConnectionPool::ConnectionHandle;
10
11pub struct Struct {
12	pub(super) ping_timeout:Duration,
13}
14
15impl Struct {
16	pub(super) fn new() -> Self { Self { ping_timeout:Duration::from_secs(5) } }
17
18	pub(super) async fn check_connection_health(&self, _handle:&mut ConnectionHandle::Struct) -> bool {
19		let start_time = Instant::now();
20
21		tokio::time::sleep(Duration::from_millis(10)).await;
22
23		let response_time = start_time.elapsed();
24
25		response_time < self.ping_timeout
26	}
27}