diff --git a/agent/src/system/health.rs b/agent/src/health.rs similarity index 98% rename from agent/src/system/health.rs rename to agent/src/health.rs index 1a0a1b6..685bd15 100644 --- a/agent/src/system/health.rs +++ b/agent/src/health.rs @@ -52,8 +52,8 @@ impl Health { /// # Usage /// Internally it uses [Arc] so it can be cheaply cloned and shared. /// ``` -/// use prymn_agent::system::health::HealthMonitor; -/// use prymn_agent::system::info::Info; +/// use prymn_agent::health::HealthMonitor; +/// use prymn_agent::info::Info; /// /// let mut info = Info::new(); /// let health_monitor = HealthMonitor::new(); diff --git a/agent/src/system/info.rs b/agent/src/info.rs similarity index 100% rename from agent/src/system/info.rs rename to agent/src/info.rs diff --git a/agent/src/lib.rs b/agent/src/lib.rs index 2dfe058..02e4f28 100644 --- a/agent/src/lib.rs +++ b/agent/src/lib.rs @@ -1,5 +1,7 @@ pub mod config; pub mod debian; +pub mod health; +pub mod info; pub mod self_update; pub mod server; -pub mod system; +pub mod task; diff --git a/agent/src/server/agent.rs b/agent/src/server/agent.rs index 563f8a6..05d49f7 100644 --- a/agent/src/server/agent.rs +++ b/agent/src/server/agent.rs @@ -7,10 +7,7 @@ use tokio_stream::{ use tokio_util::codec::{BytesCodec, FramedRead}; use tonic::{Request, Response, Status}; -use crate::{ - debian, - system::{health::HealthMonitor, info::Info, task::TaskBuilder}, -}; +use crate::{debian, health::HealthMonitor, info::Info, task::TaskBuilder}; use super::proto::*; diff --git a/agent/src/server/mod.rs b/agent/src/server/mod.rs index 099a84a..fb015b5 100644 --- a/agent/src/server/mod.rs +++ b/agent/src/server/mod.rs @@ -4,17 +4,18 @@ use tokio::{signal, sync::oneshot}; use tower_http::trace::TraceLayer; use crate::{ + health::HealthMonitor, + info, server::{agent::AgentService, proto::agent_server}, - system::{self, health::HealthMonitor}, }; mod agent; mod proto { tonic::include_proto!("prymn"); - impl From<&crate::system::health::SystemHealth> for SystemHealth { - fn from(val: &crate::system::health::SystemHealth) -> Self { - if let crate::system::health::SystemStatus::Critical(ref reasons) = val.status { + impl From<&crate::health::SystemHealth> for SystemHealth { + fn from(val: &crate::health::SystemHealth) -> Self { + if let crate::health::SystemStatus::Critical(ref reasons) = val.status { SystemHealth { status: itertools::join(reasons.iter().map(ToString::to_string), ","), } @@ -26,8 +27,8 @@ mod proto { } } - impl From<&crate::system::task::TaskStatus> for TaskHealth { - fn from(value: &crate::system::task::TaskStatus) -> Self { + impl From<&crate::task::TaskStatus> for TaskHealth { + fn from(value: &crate::task::TaskStatus) -> Self { Self { started_on: value.started_on().to_string(), progress: value.progress(), @@ -35,8 +36,8 @@ mod proto { } } - impl From<&crate::system::info::Info> for SysInfoResponse { - fn from(info: &crate::system::info::Info) -> Self { + impl From<&crate::info::Info> for SysInfoResponse { + fn from(info: &crate::info::Info) -> Self { use sysinfo::{CpuExt, DiskExt, SystemExt}; let system = info.system(); @@ -91,7 +92,7 @@ pub async fn run() -> anyhow::Result<()> { let _ = shutdown_tx.send(()); }); - let info = system::info::spawn_info_subsystem(); + let info = info::spawn_info_subsystem(); let health_monitor = HealthMonitor::new(); // Monitor system info forever diff --git a/agent/src/system/mod.rs b/agent/src/system/mod.rs deleted file mode 100644 index 0e753a6..0000000 --- a/agent/src/system/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! System boundary and modules that interact with the operating system and programs. - -pub mod health; -pub mod info; -pub mod task; diff --git a/agent/src/system/task.rs b/agent/src/task.rs similarity index 100% rename from agent/src/system/task.rs rename to agent/src/task.rs diff --git a/agent/tests/task_health.rs b/agent/tests/task_health.rs index 6db7fff..7d1f5d6 100644 --- a/agent/tests/task_health.rs +++ b/agent/tests/task_health.rs @@ -1,4 +1,4 @@ -use prymn_agent::system::{health::HealthMonitor, task::TaskBuilder}; +use prymn_agent::{health::HealthMonitor, task::TaskBuilder}; #[tokio::test] async fn task_is_gone_from_health_monitor_when_complete() {