fix: fire-and-forget checks so slow monitors don't delay fast ones
This commit is contained in:
parent
3368dbdd7f
commit
9b970a90e0
|
|
@ -9,7 +9,6 @@ reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-fe
|
|||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
scraper = "0.21" # CSS selector / HTML parsing
|
||||
futures = "0.3"
|
||||
regex = "1"
|
||||
anyhow = "1"
|
||||
tracing = "0.1"
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ pub async fn fetch_and_run(
|
|||
let n = monitors.len();
|
||||
if n == 0 { return Ok(0); }
|
||||
|
||||
// Run all checks concurrently
|
||||
let tasks: Vec<_> = monitors.into_iter().map(|monitor| {
|
||||
// Spawn all checks — fire and forget, don't block the cycle
|
||||
for monitor in monitors {
|
||||
let client = client.clone();
|
||||
let coordinator_url = coordinator_url.to_string();
|
||||
let token = token.to_string();
|
||||
|
|
@ -35,10 +35,9 @@ pub async fn fetch_and_run(
|
|||
if let Err(e) = post_result(&client, &coordinator_url, &token, result).await {
|
||||
warn!("Failed to post result for {}: {e}", monitor.id);
|
||||
}
|
||||
})
|
||||
}).collect();
|
||||
});
|
||||
}
|
||||
|
||||
futures::future::join_all(tasks).await;
|
||||
Ok(n)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue