running parallel tokio tasks for heartbeat and metrics

This commit is contained in:
2025-08-09 22:00:42 +02:00
parent a1bbbedd75
commit ac2fce75a0
7 changed files with 93 additions and 28 deletions

View File

@@ -25,14 +25,24 @@ pub struct HardwareInfo {
}
impl HardwareInfo {
pub async fn collect() -> anyhow::Result<Self, Box<dyn Error>> {
pub async fn collect() -> Result<Self, Box<dyn Error + Send + Sync>> {
let mut network_monitor = network::NetworkMonitor::new();
Ok(Self {
cpu: get_cpu_info().await?,
gpu: get_gpu_info().await?,
memory: get_memory_info().await?,
disk: get_disk_info().await?,
network: get_network_info(&mut network_monitor).await?,
network: match get_network_info(&mut network_monitor).await {
Ok(info) => info,
Err(e) => {
eprintln!("Error collecting network info: {}", e);
network::NetworkInfo {
interfaces: None,
rx_rate: None,
tx_rate: None,
}
}
},
network_monitor,
})
}