running parallel tokio tasks for heartbeat and metrics
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user