Compare commits

..

2 Commits

Author SHA1 Message Date
c165ee9cc2 renamed docker detect dto
All checks were successful
Rust Cross-Platform Build / Detect Rust Project (push) Successful in 4s
Rust Cross-Platform Build / Run Tests (push) Successful in 1m6s
Rust Cross-Platform Build / Build (x86_64-unknown-linux-gnu) (push) Successful in 2m53s
Rust Cross-Platform Build / Build (x86_64-pc-windows-gnu) (push) Successful in 3m41s
Rust Cross-Platform Build / Set Tag Name (push) Successful in 3s
Rust Cross-Platform Build / Build and Push Docker Image (push) Successful in 2m5s
Rust Cross-Platform Build / Workflow Summary (push) Successful in 2s
Rust Cross-Platform Build / Create Tag (push) Successful in 5s
2025-10-29 23:07:34 +01:00
7d6b5165c1 changed noting
All checks were successful
Rust Cross-Platform Build / Detect Rust Project (push) Successful in 5s
Rust Cross-Platform Build / Run Tests (push) Successful in 1m12s
Rust Cross-Platform Build / Build (x86_64-unknown-linux-gnu) (push) Successful in 3m3s
Rust Cross-Platform Build / Build (x86_64-pc-windows-gnu) (push) Successful in 3m57s
Rust Cross-Platform Build / Set Tag Name (push) Successful in 4s
Rust Cross-Platform Build / Build and Push Docker Image (push) Successful in 2m15s
Rust Cross-Platform Build / Workflow Summary (push) Successful in 1s
Rust Cross-Platform Build / Create Tag (push) Successful in 4s
2025-10-29 22:45:39 +01:00
4 changed files with 12 additions and 12 deletions

View File

@@ -15,7 +15,7 @@ use std::time::Duration;
use crate::docker::serverclientcomm::handle_server_message; use crate::docker::serverclientcomm::handle_server_message;
use crate::hardware::HardwareInfo; use crate::hardware::HardwareInfo;
use crate::models::{ use crate::models::{
Acknowledgment, DockerMetricDto, DockerRegistrationDto, HeartbeatDto, Acknowledgment, DockerMetricDto, DockerServiceDto, HeartbeatDto,
IdResponse, MetricDto, RegistrationDto, ServerMessage, IdResponse, MetricDto, RegistrationDto, ServerMessage,
}; };
@@ -190,7 +190,7 @@ async fn get_server_id_by_ip(
pub async fn broadcast_docker_containers( pub async fn broadcast_docker_containers(
base_url: &str, base_url: &str,
server_id: u16, server_id: u16,
container_dto: &DockerRegistrationDto, container_dto: &DockerServiceDto,
) -> Result<(), Box<dyn Error + Send + Sync>> { ) -> Result<(), Box<dyn Error + Send + Sync>> {
// First get local IP // First get local IP
println!("Preparing to broadcast docker containers..."); println!("Preparing to broadcast docker containers...");

View File

@@ -13,7 +13,7 @@ pub mod stats;
use crate::models::{ use crate::models::{
DockerCollectMetricDto, DockerContainer, DockerContainerCpuDto, DockerContainerInfo, DockerCollectMetricDto, DockerContainer, DockerContainerCpuDto, DockerContainerInfo,
DockerContainerNetworkDto, DockerContainerRamDto, DockerMetricDto, DockerRegistrationDto, DockerContainerNetworkDto, DockerContainerRamDto, DockerMetricDto, DockerServiceDto,
DockerContainerStatusDto DockerContainerStatusDto
}; };
use bollard::Docker; use bollard::Docker;
@@ -238,7 +238,7 @@ impl DockerManager {
let container_infos: Vec<DockerCollectMetricDto> = container_infos_total let container_infos: Vec<DockerCollectMetricDto> = container_infos_total
.into_iter() .into_iter()
.filter_map(|info| { .filter_map(|info| {
let container = match info.container { let _container = match info.container {
Some(c) => c, Some(c) => c,
None => { None => {
eprintln!("Warning: Container info missing container data, skipping"); eprintln!("Warning: Container info missing container data, skipping");
@@ -286,7 +286,7 @@ impl DockerManager {
}; };
Some(DockerCollectMetricDto { Some(DockerCollectMetricDto {
id: container.id, server_id: 0,
status: status_dto, status: status_dto,
cpu: cpu_dto, cpu: cpu_dto,
ram: ram_dto, ram: ram_dto,
@@ -305,12 +305,12 @@ impl DockerManager {
pub async fn create_registration_dto( pub async fn create_registration_dto(
&self, &self,
) -> Result<DockerRegistrationDto, Box<dyn Error + Send + Sync>> { ) -> Result<DockerServiceDto, Box<dyn Error + Send + Sync>> {
let containers = self.get_containers().await?; let containers = self.get_containers().await?;
let container_string = serde_json::to_value(&containers)?; let container_string = serde_json::to_value(&containers)?;
let dto = DockerRegistrationDto { let dto = DockerServiceDto {
server_id: 0, // This will be set by the caller server_id: 0, // This will be set by the caller
containers: container_string, containers: container_string,
}; };

View File

@@ -115,7 +115,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
docker_manager.create_registration_dto().await? docker_manager.create_registration_dto().await?
} else { } else {
println!("Fallback for failing registration"); println!("Fallback for failing registration");
models::DockerRegistrationDto { models::DockerServiceDto {
server_id: 0, server_id: 0,
//container_count: 0, --- IGNORE --- //container_count: 0, --- IGNORE ---
containers: serde_json::to_value(&"")?, containers: serde_json::to_value(&"")?,

View File

@@ -160,7 +160,7 @@ pub struct ServerMessage {
// Define your message structure here // Define your message structure here
pub message_type: String, pub message_type: String,
pub data: serde_json::Value, pub data: serde_json::Value,
pub message_id: String, // Add an ID for acknowledgment pub message_id: String,
} }
/// Acknowledgment payload sent to the backend server for command messages. /// Acknowledgment payload sent to the backend server for command messages.
@@ -184,7 +184,7 @@ pub struct Acknowledgment {
/// - `Name`: Container name (string) /// - `Name`: Container name (string)
/// - `Status`: Container status ("running", "stopped", etc.) /// - `Status`: Container status ("running", "stopped", etc.)
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]
pub struct DockerRegistrationDto { pub struct DockerServiceDto {
/// Unique server identifier (integer) /// Unique server identifier (integer)
#[serde(rename = "Server_id")] #[serde(rename = "Server_id")]
pub server_id: u16, pub server_id: u16,
@@ -225,7 +225,7 @@ pub struct DockerMetricDto {
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]
pub struct DockerCollectMetricDto { pub struct DockerCollectMetricDto {
pub id: String, pub server_id: u16,
pub status: DockerContainerStatusDto, pub status: DockerContainerStatusDto,
pub cpu: DockerContainerCpuDto, pub cpu: DockerContainerCpuDto,
pub ram: DockerContainerRamDto, pub ram: DockerContainerRamDto,