modulized everthing

This commit is contained in:
2025-08-08 18:59:57 +02:00
parent f0b89a9c32
commit abfa0b6fc0
11 changed files with 690 additions and 570 deletions

View File

@@ -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)