From 5fad96104f56ca57cd72366771e56f63f7f8f392 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Sat, 24 Aug 2024 05:44:51 +0900 Subject: [PATCH] refactor directory structure --- Cargo.toml | 8 ++-- Taskfile.yaml | 12 ++++- .../glommio}/Cargo.toml | 2 +- .../glommio}/src/bin/param.rs | 0 {benches_smol => benches_rt/smol}/Cargo.toml | 2 +- .../smol}/src/bin/param.rs | 0 .../tokio}/Cargo.toml | 2 +- benches_rt/tokio/src/bin/hello.rs | 20 +++++++++ .../tokio}/src/bin/param.rs | 0 .../tokio}/src/bin/sleep.rs | 0 .../vs_actix-web}/Cargo.toml | 0 .../vs_actix-web}/src/bin/param.rs | 0 benches_tokio/src/bin/hello.rs | 45 ------------------- 13 files changed, 37 insertions(+), 54 deletions(-) rename {benches_glommio => benches_rt/glommio}/Cargo.toml (83%) rename {benches_glommio => benches_rt/glommio}/src/bin/param.rs (100%) rename {benches_smol => benches_rt/smol}/Cargo.toml (83%) rename {benches_smol => benches_rt/smol}/src/bin/param.rs (100%) rename {benches_tokio => benches_rt/tokio}/Cargo.toml (83%) create mode 100644 benches_rt/tokio/src/bin/hello.rs rename {benches_tokio => benches_rt/tokio}/src/bin/param.rs (100%) rename {benches_tokio => benches_rt/tokio}/src/bin/sleep.rs (100%) rename {benches_vs_actix-web => benches_rt/vs_actix-web}/Cargo.toml (100%) rename {benches_vs_actix-web => benches_rt/vs_actix-web}/src/bin/param.rs (100%) delete mode 100644 benches_tokio/src/bin/hello.rs diff --git a/Cargo.toml b/Cargo.toml index 8d400fe3..b6ee48c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,10 +7,10 @@ members = [ ] exclude = [ "benches", - "benches_smol", - "benches_tokio", - "benches_glommio", - "benches_vs_actix-web", + "benches_rt/glommio", + "benches_rt/smol", + "benches_rt/tokio", + "benches_rt/vs_actix-web", ] [workspace.dependencies] diff --git a/Taskfile.yaml b/Taskfile.yaml index 53978939..5ec9c082 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -1,6 +1,12 @@ version: '3' tasks: + CI: + deps: + - test + - check + - bench_dryrun + test: deps: - test_doc @@ -25,8 +31,10 @@ tasks: cmds: - cd benches && cargo bench --features DEBUG --no-run - cd benches && cargo check - - cd benches_glommio && cargo check - - cd benches_smol && cargo check + - cd benches_rt/glommio && cargo check + - cd benches_rt/smol && cargo check + - cd benches_rt/tokio && cargo check + - cd benches_rt/vs_actix-web && cargo check bench: dir: benches diff --git a/benches_glommio/Cargo.toml b/benches_rt/glommio/Cargo.toml similarity index 83% rename from benches_glommio/Cargo.toml rename to benches_rt/glommio/Cargo.toml index a7ac3a69..995a30f3 100644 --- a/benches_glommio/Cargo.toml +++ b/benches_rt/glommio/Cargo.toml @@ -6,7 +6,7 @@ authors = ["kanarus "] [dependencies] # set `default-features = false` to assure "DEBUG" feature be off even when DEBUGing `../ohkami` -ohkami = { path = "../ohkami", default-features = false, features = ["rt_glommio"] } +ohkami = { path = "../../ohkami", default-features = false, features = ["rt_glommio"] } glommio = { version = "0.9" } [profile.release] diff --git a/benches_glommio/src/bin/param.rs b/benches_rt/glommio/src/bin/param.rs similarity index 100% rename from benches_glommio/src/bin/param.rs rename to benches_rt/glommio/src/bin/param.rs diff --git a/benches_smol/Cargo.toml b/benches_rt/smol/Cargo.toml similarity index 83% rename from benches_smol/Cargo.toml rename to benches_rt/smol/Cargo.toml index a0e2a7c9..dbec91f2 100644 --- a/benches_smol/Cargo.toml +++ b/benches_rt/smol/Cargo.toml @@ -6,7 +6,7 @@ authors = ["kanarus "] [dependencies] # set `default-features = false` to assure "DEBUG" feature be off even when DEBUGing `../ohkami` -ohkami = { path = "../ohkami", default-features = false, features = ["rt_smol"] } +ohkami = { path = "../../ohkami", default-features = false, features = ["rt_smol"] } smol = { version = "2" } [profile.release] diff --git a/benches_smol/src/bin/param.rs b/benches_rt/smol/src/bin/param.rs similarity index 100% rename from benches_smol/src/bin/param.rs rename to benches_rt/smol/src/bin/param.rs diff --git a/benches_tokio/Cargo.toml b/benches_rt/tokio/Cargo.toml similarity index 83% rename from benches_tokio/Cargo.toml rename to benches_rt/tokio/Cargo.toml index f2a89f4c..2afe24a9 100644 --- a/benches_tokio/Cargo.toml +++ b/benches_rt/tokio/Cargo.toml @@ -6,7 +6,7 @@ authors = ["kanarus "] [dependencies] # set `default-features = false` to assure "DEBUG" feature be off even when DEBUGing `../ohkami` -ohkami = { path = "../ohkami", default-features = false, features = ["rt_tokio"] } +ohkami = { path = "../../ohkami", default-features = false, features = ["rt_tokio"] } tokio = { version = "1", features = ["full"] } [profile.release] diff --git a/benches_rt/tokio/src/bin/hello.rs b/benches_rt/tokio/src/bin/hello.rs new file mode 100644 index 00000000..0e1b0494 --- /dev/null +++ b/benches_rt/tokio/src/bin/hello.rs @@ -0,0 +1,20 @@ +use ohkami::prelude::*; +use ohkami::format::JSON; + +#[derive(Serialize)] +struct Message { + message: String +} + +async fn hello(name: &str) -> JSON { + JSON(Message { + message: format!("Hello, {name}!") + }) +} + +#[tokio::main] +async fn main() { + Ohkami::new(( + "/hello/:name".GET(hello), + )).howl("localhost:3000").await +} diff --git a/benches_tokio/src/bin/param.rs b/benches_rt/tokio/src/bin/param.rs similarity index 100% rename from benches_tokio/src/bin/param.rs rename to benches_rt/tokio/src/bin/param.rs diff --git a/benches_tokio/src/bin/sleep.rs b/benches_rt/tokio/src/bin/sleep.rs similarity index 100% rename from benches_tokio/src/bin/sleep.rs rename to benches_rt/tokio/src/bin/sleep.rs diff --git a/benches_vs_actix-web/Cargo.toml b/benches_rt/vs_actix-web/Cargo.toml similarity index 100% rename from benches_vs_actix-web/Cargo.toml rename to benches_rt/vs_actix-web/Cargo.toml diff --git a/benches_vs_actix-web/src/bin/param.rs b/benches_rt/vs_actix-web/src/bin/param.rs similarity index 100% rename from benches_vs_actix-web/src/bin/param.rs rename to benches_rt/vs_actix-web/src/bin/param.rs diff --git a/benches_tokio/src/bin/hello.rs b/benches_tokio/src/bin/hello.rs deleted file mode 100644 index 7dc3b4f0..00000000 --- a/benches_tokio/src/bin/hello.rs +++ /dev/null @@ -1,45 +0,0 @@ -use ohkami::prelude::*; -use ohkami::format::JSON; - -#[cfg(feature="DEBUG")] -#[derive(Clone)] -struct Logger; -#[cfg(feature="DEBUG")] -impl FangAction for Logger { - async fn fore<'a>(&'a self, req: &'a mut Request) -> Result<(), Response> { - tracing::info!("\n{req:?}"); - Ok(()) - } - async fn back<'a>(&'a self, res: &'a mut Response) { - tracing::info!("\n{res:?}"); - } -} - -#[derive(Serialize)] -struct Message { - message: String -} - -async fn hello(name: &str) -> JSON { - JSON(Message { - message: format!("Hello, {name}!") - }) -} - -#[tokio::main] -async fn main() { - #[cfg(feature="DEBUG")] - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .init(); - - #[cfg(feature="DEBUG")] - let fangs = Logger; - - #[cfg(not(feature="DEBUG"))] - let fangs = (); - - Ohkami::with(fangs, ( - "/hello/:name".GET(hello), - )).howl("localhost:3000").await -}