refactor: move system all modules to root
This commit is contained in:
parent
5c64f02579
commit
085e000009
8 changed files with 17 additions and 22 deletions
|
@ -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();
|
|
@ -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;
|
||||
|
|
|
@ -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::*;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue