removed drecks loop

This commit is contained in:
2025-08-09 22:08:04 +02:00
parent ac2fce75a0
commit cab92df37e

View File

@@ -124,7 +124,7 @@ pub async fn heartbeat_loop(base_url: &str, ip: &str) -> Result<(), Box<dyn Erro
match client.post(&url).json(&payload).send().await {
Ok(res) if res.status().is_success() => {
println!("Heartbeat sent successfully.");
println!("Heartbeat sent successfully.");
}
Ok(res) => eprintln!("Server responded with status: {}", res.status()),
Err(e) => eprintln!("Heartbeat error: {}", e),
@@ -140,20 +140,15 @@ pub async fn send_metrics(
) -> Result<(), Box<dyn Error + Send + Sync>> {
let client = Client::new();
let url = format!("{}/monitoring/metric", base_url);
let mut interval = interval(Duration::from_secs(20));
loop {
interval.tick().await;
let metric = metrics;
eprintln!("Sending metrics: {:?}", metric);
match client.post(&url).json(&metric).send().await {
Ok(res) => println!(
"✅ Sent metrics for server {} | Status: {}",
metric.server_id,
res.status()
),
Err(err) => eprintln!("❌ Failed to send metrics: {}", err),
}
match client.post(&url).json(&metrics).send().await {
Ok(res) => println!(
"✅ Sent metrics for server {} | Status: {}",
metrics.server_id,
res.status()
),
Err(err) => eprintln!("❌ Failed to send metrics: {}", err),
}
Ok(())
}