Compare commits
2 Commits
2a4cc4b2d5
...
v0.1.33
| Author | SHA1 | Date | |
|---|---|---|---|
| c165ee9cc2 | |||
| 7d6b5165c1 |
@@ -15,7 +15,7 @@ use std::time::Duration;
|
||||
use crate::docker::serverclientcomm::handle_server_message;
|
||||
use crate::hardware::HardwareInfo;
|
||||
use crate::models::{
|
||||
Acknowledgment, DockerMetricDto, DockerRegistrationDto, HeartbeatDto,
|
||||
Acknowledgment, DockerMetricDto, DockerServiceDto, HeartbeatDto,
|
||||
IdResponse, MetricDto, RegistrationDto, ServerMessage,
|
||||
};
|
||||
|
||||
@@ -190,7 +190,7 @@ async fn get_server_id_by_ip(
|
||||
pub async fn broadcast_docker_containers(
|
||||
base_url: &str,
|
||||
server_id: u16,
|
||||
container_dto: &DockerRegistrationDto,
|
||||
container_dto: &DockerServiceDto,
|
||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
// First get local IP
|
||||
println!("Preparing to broadcast docker containers...");
|
||||
|
||||
@@ -13,7 +13,7 @@ pub mod stats;
|
||||
|
||||
use crate::models::{
|
||||
DockerCollectMetricDto, DockerContainer, DockerContainerCpuDto, DockerContainerInfo,
|
||||
DockerContainerNetworkDto, DockerContainerRamDto, DockerMetricDto, DockerRegistrationDto,
|
||||
DockerContainerNetworkDto, DockerContainerRamDto, DockerMetricDto, DockerServiceDto,
|
||||
DockerContainerStatusDto
|
||||
};
|
||||
use bollard::Docker;
|
||||
@@ -238,7 +238,7 @@ impl DockerManager {
|
||||
let container_infos: Vec<DockerCollectMetricDto> = container_infos_total
|
||||
.into_iter()
|
||||
.filter_map(|info| {
|
||||
let container = match info.container {
|
||||
let _container = match info.container {
|
||||
Some(c) => c,
|
||||
None => {
|
||||
eprintln!("Warning: Container info missing container data, skipping");
|
||||
@@ -286,7 +286,7 @@ impl DockerManager {
|
||||
};
|
||||
|
||||
Some(DockerCollectMetricDto {
|
||||
id: container.id,
|
||||
server_id: 0,
|
||||
status: status_dto,
|
||||
cpu: cpu_dto,
|
||||
ram: ram_dto,
|
||||
@@ -305,12 +305,12 @@ impl DockerManager {
|
||||
|
||||
pub async fn create_registration_dto(
|
||||
&self,
|
||||
) -> Result<DockerRegistrationDto, Box<dyn Error + Send + Sync>> {
|
||||
) -> Result<DockerServiceDto, Box<dyn Error + Send + Sync>> {
|
||||
let containers = self.get_containers().await?;
|
||||
|
||||
let container_string = serde_json::to_value(&containers)?;
|
||||
|
||||
let dto = DockerRegistrationDto {
|
||||
let dto = DockerServiceDto {
|
||||
server_id: 0, // This will be set by the caller
|
||||
containers: container_string,
|
||||
};
|
||||
|
||||
@@ -115,7 +115,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
docker_manager.create_registration_dto().await?
|
||||
} else {
|
||||
println!("Fallback for failing registration");
|
||||
models::DockerRegistrationDto {
|
||||
models::DockerServiceDto {
|
||||
server_id: 0,
|
||||
//container_count: 0, --- IGNORE ---
|
||||
containers: serde_json::to_value(&"")?,
|
||||
|
||||
@@ -160,7 +160,7 @@ pub struct ServerMessage {
|
||||
// Define your message structure here
|
||||
pub message_type: String,
|
||||
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.
|
||||
@@ -184,7 +184,7 @@ pub struct Acknowledgment {
|
||||
/// - `Name`: Container name (string)
|
||||
/// - `Status`: Container status ("running", "stopped", etc.)
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
pub struct DockerRegistrationDto {
|
||||
pub struct DockerServiceDto {
|
||||
/// Unique server identifier (integer)
|
||||
#[serde(rename = "Server_id")]
|
||||
pub server_id: u16,
|
||||
@@ -225,7 +225,7 @@ pub struct DockerMetricDto {
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
||||
pub struct DockerCollectMetricDto {
|
||||
pub id: String,
|
||||
pub server_id: u16,
|
||||
pub status: DockerContainerStatusDto,
|
||||
pub cpu: DockerContainerCpuDto,
|
||||
pub ram: DockerContainerRamDto,
|
||||
|
||||
Reference in New Issue
Block a user