From 14855ef23f93575f28c0ee7a6da950858324d918 Mon Sep 17 00:00:00 2001 From: Didier Wenzek Date: Wed, 30 Oct 2024 10:57:22 +0100 Subject: [PATCH] Merge log_manager crate under tedge_log_manager Signed-off-by: Didier Wenzek --- Cargo.lock | 25 ++++------------ Cargo.toml | 1 - crates/common/log_manager/Cargo.toml | 29 ------------------- .../extensions/tedge_log_manager/Cargo.toml | 8 ++++- .../extensions/tedge_log_manager/src/actor.rs | 4 +-- .../extensions/tedge_log_manager/src/error.rs | 2 +- .../extensions/tedge_log_manager/src/lib.rs | 3 +- .../tedge_log_manager/src/manager}/config.rs | 0 .../tedge_log_manager/src/manager}/error.rs | 0 .../src/manager}/log_utils.rs | 2 +- .../tedge_log_manager/src/manager/mod.rs} | 0 11 files changed, 19 insertions(+), 55 deletions(-) delete mode 100644 crates/common/log_manager/Cargo.toml rename crates/{common/log_manager/src => extensions/tedge_log_manager/src/manager}/config.rs (100%) rename crates/{common/log_manager/src => extensions/tedge_log_manager/src/manager}/error.rs (100%) rename crates/{common/log_manager/src => extensions/tedge_log_manager/src/manager}/log_utils.rs (99%) rename crates/{common/log_manager/src/lib.rs => extensions/tedge_log_manager/src/manager/mod.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index bead0138642..78cb4c384ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2019,24 +2019,6 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -[[package]] -name = "log_manager" -version = "1.3.1" -dependencies = [ - "easy_reader", - "filetime", - "glob", - "log", - "rand", - "regex", - "serde", - "tedge_test_utils", - "tedge_utils", - "thiserror", - "time", - "toml 0.7.8", -] - [[package]] name = "maplit" version = "1.0.2" @@ -4119,9 +4101,13 @@ dependencies = [ "assert-json-diff", "async-trait", "camino", + "easy_reader", "filetime", + "glob", "log", - "log_manager", + "rand", + "regex", + "serde", "serde_json", "tedge_actors", "tedge_api", @@ -4132,6 +4118,7 @@ dependencies = [ "tedge_uploader_ext", "tedge_utils", "thiserror", + "time", "tokio", "toml 0.7.8", ] diff --git a/Cargo.toml b/Cargo.toml index 53c3a48e994..35125992bc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,6 @@ itertools = "0.13" json-writer = { path = "crates/common/json_writer" } lazy_static = "1.4" log = "0.4" -log_manager = { path = "crates/common/log_manager" } maplit = "1.0" miette = { version = "5.5.0", features = ["fancy"] } mime = "0.3.17" diff --git a/crates/common/log_manager/Cargo.toml b/crates/common/log_manager/Cargo.toml deleted file mode 100644 index 31f5f4c6cc9..00000000000 --- a/crates/common/log_manager/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "log_manager" -version = { workspace = true } -authors = { workspace = true } -edition = { workspace = true } -rust-version = { workspace = true } -license = { workspace = true } -homepage = { workspace = true } -repository = { workspace = true } - -[dependencies] -easy_reader = { workspace = true } -glob = { workspace = true } -log = { workspace = true } -rand = { workspace = true } -regex = { workspace = true } -serde = { workspace = true, features = ["derive"] } -tedge_utils = { workspace = true } -thiserror = { workspace = true } -time = { workspace = true, features = ["formatting"] } -toml = { workspace = true } - -[dev-dependencies] -filetime = { workspace = true } -tedge_test_utils = { workspace = true } -time = { workspace = true, features = ["macros"] } - -[lints] -workspace = true diff --git a/crates/extensions/tedge_log_manager/Cargo.toml b/crates/extensions/tedge_log_manager/Cargo.toml index 50ee305442d..2d808858d17 100644 --- a/crates/extensions/tedge_log_manager/Cargo.toml +++ b/crates/extensions/tedge_log_manager/Cargo.toml @@ -12,8 +12,12 @@ repository = { workspace = true } [dependencies] async-trait = { workspace = true } camino = { workspace = true } +easy_reader = { workspace = true } +glob = { workspace = true } log = { workspace = true } -log_manager = { workspace = true } +rand = { workspace = true } +regex = { workspace = true } +serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } tedge_actors = { workspace = true } tedge_api = { workspace = true } @@ -22,6 +26,7 @@ tedge_file_system_ext = { workspace = true } tedge_mqtt_ext = { workspace = true } tedge_uploader_ext = { workspace = true } tedge_utils = { workspace = true } +time = { workspace = true, features = ["formatting"] } thiserror = { workspace = true } tokio = { workspace = true, features = ["macros"] } toml = { workspace = true } @@ -32,6 +37,7 @@ assert-json-diff = { workspace = true } filetime = { workspace = true } tedge_actors = { workspace = true, features = ["test-helpers"] } tedge_test_utils = { workspace = true } +time = { workspace = true, features = ["macros"] } [lints] workspace = true diff --git a/crates/extensions/tedge_log_manager/src/actor.rs b/crates/extensions/tedge_log_manager/src/actor.rs index 06202d8a315..d53a8e48945 100644 --- a/crates/extensions/tedge_log_manager/src/actor.rs +++ b/crates/extensions/tedge_log_manager/src/actor.rs @@ -1,12 +1,12 @@ use std::collections::HashMap; +use crate::manager::LogPluginConfig; use async_trait::async_trait; use camino::Utf8Path; use log::debug; use log::error; use log::info; use log::warn; -use log_manager::LogPluginConfig; use tedge_actors::fan_in_message_type; use tedge_actors::Actor; use tedge_actors::ChannelError; @@ -156,7 +156,7 @@ impl LogManagerActor { ) -> Result<(), LogManagementError> { let topic = request.topic(&self.config.mqtt_schema).as_ref().to_string(); let request = &request.payload; - let log_path = log_manager::new_read_logs( + let log_path = crate::manager::new_read_logs( &self.plugin_config.files, &request.log_type, request.date_from, diff --git a/crates/extensions/tedge_log_manager/src/error.rs b/crates/extensions/tedge_log_manager/src/error.rs index 4f61faf6360..36974f24883 100644 --- a/crates/extensions/tedge_log_manager/src/error.rs +++ b/crates/extensions/tedge_log_manager/src/error.rs @@ -18,7 +18,7 @@ pub enum LogManagementError { FromPathsError(#[from] tedge_utils::paths::PathsError), #[error(transparent)] - FromLogRetrievalError(#[from] log_manager::LogRetrievalError), + FromLogRetrievalError(#[from] crate::manager::LogRetrievalError), } impl From for tedge_actors::RuntimeError { diff --git a/crates/extensions/tedge_log_manager/src/lib.rs b/crates/extensions/tedge_log_manager/src/lib.rs index f263ac05b39..61a8c8c009f 100644 --- a/crates/extensions/tedge_log_manager/src/lib.rs +++ b/crates/extensions/tedge_log_manager/src/lib.rs @@ -1,6 +1,7 @@ mod actor; mod config; mod error; +mod manager; #[cfg(test)] mod tests; @@ -8,7 +9,7 @@ mod tests; pub use actor::*; pub use config::*; use log::error; -use log_manager::LogPluginConfig; +use manager::LogPluginConfig; use std::path::PathBuf; use tedge_actors::Builder; use tedge_actors::CloneSender; diff --git a/crates/common/log_manager/src/config.rs b/crates/extensions/tedge_log_manager/src/manager/config.rs similarity index 100% rename from crates/common/log_manager/src/config.rs rename to crates/extensions/tedge_log_manager/src/manager/config.rs diff --git a/crates/common/log_manager/src/error.rs b/crates/extensions/tedge_log_manager/src/manager/error.rs similarity index 100% rename from crates/common/log_manager/src/error.rs rename to crates/extensions/tedge_log_manager/src/manager/error.rs diff --git a/crates/common/log_manager/src/log_utils.rs b/crates/extensions/tedge_log_manager/src/manager/log_utils.rs similarity index 99% rename from crates/common/log_manager/src/log_utils.rs rename to crates/extensions/tedge_log_manager/src/manager/log_utils.rs index 1515fcb3504..fa25002b36c 100644 --- a/crates/common/log_manager/src/log_utils.rs +++ b/crates/extensions/tedge_log_manager/src/manager/log_utils.rs @@ -175,7 +175,7 @@ mod tests { use std::io::Write; use super::*; - use crate::FileEntry; + use crate::manager::FileEntry; use filetime::set_file_mtime; use filetime::FileTime; use tedge_test_utils::fs::TempTedgeDir; diff --git a/crates/common/log_manager/src/lib.rs b/crates/extensions/tedge_log_manager/src/manager/mod.rs similarity index 100% rename from crates/common/log_manager/src/lib.rs rename to crates/extensions/tedge_log_manager/src/manager/mod.rs