From e3996fdb84e3261462fa682c63302450e5dd6799 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Fri, 28 Nov 2025 13:01:36 +0100 Subject: [PATCH] Fix compilation errors from command receiver removal - Remove AgentCommand import from agent.rs - Remove handle_commands() method - Remove command handling from main loop - Remove command_port validation checks --- Cargo.lock | 6 ++--- agent/src/agent.rs | 40 +--------------------------------- agent/src/config/validation.rs | 8 ------- 3 files changed, 4 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc8849f..405acec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.191" +version = "0.1.203" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.191" +version = "0.1.203" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.191" +version = "0.1.203" dependencies = [ "chrono", "serde", diff --git a/agent/src/agent.rs b/agent/src/agent.rs index d74a4c7..e6eeb47 100644 --- a/agent/src/agent.rs +++ b/agent/src/agent.rs @@ -4,7 +4,7 @@ use std::time::Duration; use tokio::time::interval; use tracing::{debug, error, info}; -use crate::communication::{AgentCommand, ZmqHandler}; +use crate::communication::ZmqHandler; use crate::config::AgentConfig; use crate::collectors::{ Collector, @@ -134,12 +134,6 @@ impl Agent { // NOTE: With structured data, we might need to implement status tracking differently // For now, we skip this until status evaluation is migrated } - // Handle incoming commands (check periodically) - _ = tokio::time::sleep(Duration::from_millis(100)) => { - if let Err(e) = self.handle_commands().await { - error!("Error handling commands: {}", e); - } - } _ = &mut shutdown_rx => { info!("Shutdown signal received, stopping agent loop"); break; @@ -259,36 +253,4 @@ impl Agent { Ok(()) } - /// Handle incoming commands from dashboard - async fn handle_commands(&mut self) -> Result<()> { - // Try to receive a command (non-blocking) - if let Ok(Some(command)) = self.zmq_handler.try_receive_command() { - info!("Received command: {:?}", command); - - match command { - AgentCommand::CollectNow => { - info!("Received immediate collection request"); - if let Err(e) = self.collect_and_broadcast().await { - error!("Failed to collect on demand: {}", e); - } - } - AgentCommand::SetInterval { seconds } => { - info!("Received interval change request: {}s", seconds); - // Note: This would require more complex handling to update the interval - // For now, just acknowledge - } - AgentCommand::ToggleCollector { name, enabled } => { - info!("Received collector toggle request: {} -> {}", name, enabled); - // Note: This would require more complex handling to enable/disable collectors - // For now, just acknowledge - } - AgentCommand::Ping => { - info!("Received ping command"); - // Maybe send back a pong or status - } - } - } - Ok(()) - } - } \ No newline at end of file diff --git a/agent/src/config/validation.rs b/agent/src/config/validation.rs index 2747418..410770d 100644 --- a/agent/src/config/validation.rs +++ b/agent/src/config/validation.rs @@ -7,14 +7,6 @@ pub fn validate_config(config: &AgentConfig) -> Result<()> { bail!("ZMQ publisher port cannot be 0"); } - if config.zmq.command_port == 0 { - bail!("ZMQ command port cannot be 0"); - } - - if config.zmq.publisher_port == config.zmq.command_port { - bail!("ZMQ publisher and command ports cannot be the same"); - } - if config.zmq.bind_address.is_empty() { bail!("ZMQ bind address cannot be empty"); }