MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / run_check

Function run_check

crates/openshell-server/src/readiness.rs:182–201  ·  view source on GitHub ↗
(store: &Store, timeout: Duration)

Source from the content-addressed store, hash-verified

180}
181
182async fn run_check(store: &Store, timeout: Duration) -> HealthState {
183 let started = Instant::now();
184 match tokio::time::timeout(timeout, store.ping()).await {
185 Ok(Ok(())) => HealthState::Healthy {
186 latency_ms: elapsed_ms(started.elapsed()),
187 },
188 Ok(Err(err)) => {
189 let latency_ms = elapsed_ms(started.elapsed());
190 warn!(error = %err, latency_ms, "database health check failed");
191 HealthState::Unhealthy(HealthError::Unavailable { latency_ms })
192 }
193 Err(_) => {
194 warn!(
195 timeout_ms = u64::try_from(timeout.as_millis()).unwrap_or(u64::MAX),
196 "database health check timed out"
197 );
198 HealthState::Unhealthy(HealthError::Timeout)
199 }
200 }
201}
202
203fn record_metrics(state: &HealthState) {
204 let (healthy, outcome_label, latency_seconds) = match state {

Callers 1

monitor_loopFunction · 0.85

Calls 2

elapsed_msFunction · 0.85
pingMethod · 0.45

Tested by

no test coverage detected