This commit is contained in:
nate 2026-04-08 14:42:08 +04:00
parent 981ed965a8
commit 1434330545
1 changed files with 10 additions and 3 deletions

View File

@ -26,13 +26,20 @@ pub async fn fetch_and_run(
in_flight: &Arc<Mutex<HashSet<String>>>,
) -> Result<usize> {
let url = format!("{coordinator_url}/internal/due?region={region}&lookahead_ms=2000");
let monitors: Vec<Monitor> = client
let resp = client
.get(&url)
.header("x-monitor-token", token)
.send()
.await?
.json()
.await?;
let status = resp.status();
let body = resp.text().await?;
let monitors: Vec<Monitor> = match serde_json::from_str(&body) {
Ok(m) => m,
Err(e) => {
let preview: String = body.chars().take(500).collect();
anyhow::bail!("/internal/due returned status {status}, body could not be parsed: {e}. Body preview: {preview}");
}
};
let n = monitors.len();
if n == 0 { return Ok(0); }