modulized everthing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::hardware::HardwareInfo;
|
||||
use crate::models::{HardwareDto, HeartbeatDto, IdResponse, MetricDto, RegistrationDto};
|
||||
use anyhow::Result;
|
||||
use reqwest::{Client, StatusCode};
|
||||
@@ -20,16 +21,16 @@ pub async fn register_with_server(base_url: &str) -> Result<(i32, String), Box<d
|
||||
.build()?;
|
||||
|
||||
// Collect hardware info
|
||||
let hardware = HardwareDto::collect().await?;
|
||||
let hardware = HardwareInfo::collect().await?;
|
||||
|
||||
// Prepare registration data
|
||||
let registration = RegistrationDto {
|
||||
id: server_id,
|
||||
ip_address: registered_ip.clone(),
|
||||
cpu_type: hardware.cpu_type,
|
||||
cpu_cores: hardware.cpu_cores,
|
||||
gpu_type: hardware.gpu_type,
|
||||
ram_size: hardware.ram_size,
|
||||
cpu_type: hardware.cpu.name.clone().unwrap_or_default(),
|
||||
cpu_cores: (hardware.cpu.cores).unwrap_or_default(),
|
||||
gpu_type: hardware.gpu.name.clone().unwrap_or_default(),
|
||||
ram_size: hardware.memory.total.unwrap_or_default(),
|
||||
};
|
||||
|
||||
// Try to register (will retry on failure)
|
||||
|
Reference in New Issue
Block a user