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

Function monitor_loop

crates/openshell-server/src/readiness.rs:158–180  ·  view source on GitHub ↗
(
    store: Arc<Store>,
    tx: watch::Sender<HealthState>,
    interval: Duration,
    timeout: Duration,
)

Source from the content-addressed store, hash-verified

156}
157
158async fn monitor_loop(
159 store: Arc<Store>,
160 tx: watch::Sender<HealthState>,
161 interval: Duration,
162 timeout: Duration,
163) {
164 let mut ticker = tokio::time::interval(interval);
165 // `Skip` keeps the schedule when a tick is missed (e.g. because a ping
166 // approached the timeout). `Burst` (the default) would fire back-to-back
167 // catch-up pings, defeating the bounded-cadence guarantee.
168 ticker.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
169
170 loop {
171 ticker.tick().await;
172 let state = run_check(store.as_ref(), timeout).await;
173 record_metrics(&state);
174 // Send errors only happen when every receiver is dropped, at which
175 // point the monitor is shutting down — exit cleanly.
176 if tx.send(state).is_err() {
177 break;
178 }
179 }
180}
181
182async fn run_check(store: &Store, timeout: Duration) -> HealthState {
183 let started = Instant::now();

Callers 1

spawn_withMethod · 0.85

Calls 2

run_checkFunction · 0.85
record_metricsFunction · 0.85

Tested by

no test coverage detected