From 3585e8a2efaec307c18ce1660570e45fcfc138b7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 29 Apr 2024 13:56:04 -0700 Subject: [PATCH] rename / simplify tester stub for now Signed-off-by: Jason Volk Signed-off-by: strawberry --- Cargo.lock | 5 ----- Cargo.toml | 10 +--------- hot_lib/Cargo.toml | 10 ---------- hot_lib/src/lib.rs | 7 ------- src/service/admin/mod.rs | 15 ++++----------- src/service/admin/tester/mod.rs | 14 ++++++++++++++ 6 files changed, 19 insertions(+), 42 deletions(-) delete mode 100644 hot_lib/Cargo.toml delete mode 100644 hot_lib/src/lib.rs create mode 100644 src/service/admin/tester/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 9b45b7c2..77d56e74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -567,7 +567,6 @@ dependencies = [ "hickory-resolver", "hmac", "hot-lib-reloader", - "hot_lib", "http 1.1.0", "http-body-util", "hyper 1.3.1", @@ -1347,10 +1346,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "hot_lib" -version = "0.1.0" - [[package]] name = "html5ever" version = "0.26.0" diff --git a/Cargo.toml b/Cargo.toml index 210826a3..df075772 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,19 +16,11 @@ edition = "2021" # See also `rust-toolchain.toml` rust-version = "1.76.0" -# for hot lib reload -[workspace] -members = ["hot_lib"] - [dependencies] console-subscriber = { version = "0.1", optional = true } # for hot lib reload -# see https://github.com/rksm/hot-lib-reloader-rs?tab=readme-ov-file#usage for more details if you are a dev hot-lib-reloader = { version = "^0.7", optional = true } -hot_lib = { path = "hot_lib", optional = true } -# not sure if we need this, will anyone be using hot lib reload on release profile? -#no-mangle-if-debug = { version = "*" } # Used for secure identifiers rand = "0.8.5" @@ -408,7 +400,7 @@ perf_measurements = [ # incompatible with release_max_log_level tokio_console = ["console-subscriber", "tokio/tracing"] -hot_reload = ["dep:hot-lib-reloader", "hot_lib"] +hot_reload = ["dep:hot-lib-reloader"] hardened_malloc = ["hardened_malloc-rs"] diff --git a/hot_lib/Cargo.toml b/hot_lib/Cargo.toml deleted file mode 100644 index bb6eaa71..00000000 --- a/hot_lib/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "hot_lib" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["rlib", "dylib"] - -# cargo watch -w hot_lib -x 'build -p hot_lib' -# ^this will rebuild upon cargo detecting any changes diff --git a/hot_lib/src/lib.rs b/hot_lib/src/lib.rs deleted file mode 100644 index b661f401..00000000 --- a/hot_lib/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! hot reloadable functions, generally called by the admin room test commands -//! see for more details if you are a dev - -#[no_mangle] -pub fn test_command() { - println!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); -} diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index b6b810bd..8907869e 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -26,10 +26,7 @@ use serde_json::value::to_raw_value; use tokio::sync::{Mutex, MutexGuard}; use tracing::{error, warn}; -use self::fsck::FsckCommand; -#[cfg(feature = "hot_reload")] -#[allow(unused_imports)] -use self::test_cmd::TestCommands; +use self::{fsck::FsckCommand, tester::TesterCommands}; use super::pdu::PduBuilder; use crate::{ service::admin::{ @@ -47,9 +44,7 @@ pub(crate) mod media; pub(crate) mod query; pub(crate) mod room; pub(crate) mod server; -#[cfg(feature = "hot_reload")] -#[allow(unused_imports)] -pub(crate) mod test_cmd; +pub(crate) mod tester; pub(crate) mod user; const PAGE_SIZE: usize = 100; @@ -94,9 +89,8 @@ enum AdminCommand { /// - Query all the database getters and iterators Fsck(FsckCommand), - #[cfg(feature = "hot_reload")] #[command(subcommand)] - Test(TestCommands), + Tester(TesterCommands), } #[derive(Debug)] @@ -314,8 +308,7 @@ impl Service { AdminCommand::Debug(command) => debug::process(command, body).await?, AdminCommand::Query(command) => query::process(command, body).await?, AdminCommand::Fsck(command) => fsck::process(command, body).await?, - #[cfg(feature = "hot_reload")] - AdminCommand::Test(command) => test_cmd::process(command, body).await?, + AdminCommand::Tester(command) => tester::process(command, body).await?, }; Ok(reply_message_content) diff --git a/src/service/admin/tester/mod.rs b/src/service/admin/tester/mod.rs new file mode 100644 index 00000000..c0f3df15 --- /dev/null +++ b/src/service/admin/tester/mod.rs @@ -0,0 +1,14 @@ +use ruma::events::room::message::RoomMessageEventContent; + +use crate::Result; + +#[cfg_attr(test, derive(Debug))] +#[derive(clap::Subcommand)] +pub(crate) enum TesterCommands { + Tester, +} +pub(crate) async fn process(command: TesterCommands, _body: Vec<&str>) -> Result { + Ok(match command { + TesterCommands::Tester => RoomMessageEventContent::notice_plain(String::from("complete")), + }) +}