From 6abbf54c6a150d6d33f72d2dff22226b7e1c0ca8 Mon Sep 17 00:00:00 2001 From: kanarus Date: Sun, 26 Jan 2025 08:39:23 +0900 Subject: [PATCH 1/4] bump ohkami to v0.21 --- rust/ohkami/Cargo.toml | 4 ++-- rust/ohkami/config.yaml | 2 +- rust/ohkami/src/main.rs | 13 +++---------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/rust/ohkami/Cargo.toml b/rust/ohkami/Cargo.toml index 4679885cce5..5fc7082c7f1 100644 --- a/rust/ohkami/Cargo.toml +++ b/rust/ohkami/Cargo.toml @@ -16,5 +16,5 @@ rpath = false strip = false [dependencies] -ohkami = { version = "0.20", features = ["rt_tokio"] } -tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +ohkami = { version = "0.21", features = ["rt_tokio"] } +nio = { version = "0.0" } diff --git a/rust/ohkami/config.yaml b/rust/ohkami/config.yaml index c3f364602ab..567b9299287 100644 --- a/rust/ohkami/config.yaml +++ b/rust/ohkami/config.yaml @@ -1,3 +1,3 @@ framework: github: ohkami-rs/ohkami - version: 0.20 + version: 0.21 diff --git a/rust/ohkami/src/main.rs b/rust/ohkami/src/main.rs index 6238c7b3685..ca90817e7ae 100644 --- a/rust/ohkami/src/main.rs +++ b/rust/ohkami/src/main.rs @@ -1,6 +1,7 @@ use ohkami::prelude::*; -fn benchmark_ohkami() -> Ohkami { +#[nio::main] +async fn main() { Ohkami::new(( "/" .GET(|| async {Response::OK()}), @@ -8,13 +9,5 @@ fn benchmark_ohkami() -> Ohkami { .POST(|| async {Response::OK()}), "/user/:id" .GET(|id: String| async {id}), - )) -} - -fn main() { - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .event_interval(1) - .build().unwrap() - .block_on(benchmark_ohkami().howl("0.0.0.0:3000")) + )).howl("0.0.0.0:3000").await } From 5ac65afd107968941642608cd2cd18cf90d6e31f Mon Sep 17 00:00:00 2001 From: kanarus Date: Mon, 27 Jan 2025 03:21:13 +0900 Subject: [PATCH 2/4] fix ohkami's `features` --- rust/ohkami/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/ohkami/Cargo.toml b/rust/ohkami/Cargo.toml index 5fc7082c7f1..12bcc064fdd 100644 --- a/rust/ohkami/Cargo.toml +++ b/rust/ohkami/Cargo.toml @@ -16,5 +16,5 @@ rpath = false strip = false [dependencies] -ohkami = { version = "0.21", features = ["rt_tokio"] } +ohkami = { version = "0.21", features = ["rt_nio"] } nio = { version = "0.0" } From b3f88d1a6c953b5bc2eebd82beafcd834201009a Mon Sep 17 00:00:00 2001 From: kanarus Date: Mon, 27 Jan 2025 05:03:46 +0900 Subject: [PATCH 3/4] create `ohkami-nio` and `ohkami-tokio` instead of just `ohkami` --- rust/{ohkami => ohkami-nio}/Cargo.toml | 10 ++-------- rust/{ohkami => ohkami-nio}/config.yaml | 2 ++ rust/{ohkami => ohkami-nio}/src/main.rs | 0 rust/ohkami-tokio/Cargo.toml | 14 ++++++++++++++ rust/ohkami-tokio/config.yaml | 5 +++++ rust/ohkami-tokio/src/main.rs | 13 +++++++++++++ 6 files changed, 36 insertions(+), 8 deletions(-) rename rust/{ohkami => ohkami-nio}/Cargo.toml (62%) rename rust/{ohkami => ohkami-nio}/config.yaml (72%) rename rust/{ohkami => ohkami-nio}/src/main.rs (100%) create mode 100644 rust/ohkami-tokio/Cargo.toml create mode 100644 rust/ohkami-tokio/config.yaml create mode 100644 rust/ohkami-tokio/src/main.rs diff --git a/rust/ohkami/Cargo.toml b/rust/ohkami-nio/Cargo.toml similarity index 62% rename from rust/ohkami/Cargo.toml rename to rust/ohkami-nio/Cargo.toml index 12bcc064fdd..d24e7c79254 100644 --- a/rust/ohkami/Cargo.toml +++ b/rust/ohkami-nio/Cargo.toml @@ -5,15 +5,9 @@ edition = "2021" publish = false [profile.release] -opt-level = 3 -debug = false -debug-assertions = false -lto = true -panic = "abort" -incremental = false +lto = true +panic = "abort" codegen-units = 1 -rpath = false -strip = false [dependencies] ohkami = { version = "0.21", features = ["rt_nio"] } diff --git a/rust/ohkami/config.yaml b/rust/ohkami-nio/config.yaml similarity index 72% rename from rust/ohkami/config.yaml rename to rust/ohkami-nio/config.yaml index 567b9299287..efddff39729 100644 --- a/rust/ohkami/config.yaml +++ b/rust/ohkami-nio/config.yaml @@ -1,3 +1,5 @@ framework: github: ohkami-rs/ohkami version: 0.21 + engines: + - nio diff --git a/rust/ohkami/src/main.rs b/rust/ohkami-nio/src/main.rs similarity index 100% rename from rust/ohkami/src/main.rs rename to rust/ohkami-nio/src/main.rs diff --git a/rust/ohkami-tokio/Cargo.toml b/rust/ohkami-tokio/Cargo.toml new file mode 100644 index 00000000000..3879d5131c5 --- /dev/null +++ b/rust/ohkami-tokio/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "server" +version = "0.0.0" +edition = "2021" +publish = false + +[profile.release] +lto = true +panic = "abort" +codegen-units = 1 + +[dependencies] +ohkami = { version = "0.21", features = ["rt_tokio"] } +tokio = { version = "1.43", features = ["full"] } diff --git a/rust/ohkami-tokio/config.yaml b/rust/ohkami-tokio/config.yaml new file mode 100644 index 00000000000..8d5cfeeb421 --- /dev/null +++ b/rust/ohkami-tokio/config.yaml @@ -0,0 +1,5 @@ +framework: + github: ohkami-rs/ohkami + version: 0.21 + engines: + - tokio diff --git a/rust/ohkami-tokio/src/main.rs b/rust/ohkami-tokio/src/main.rs new file mode 100644 index 00000000000..7fcf8fd5a4a --- /dev/null +++ b/rust/ohkami-tokio/src/main.rs @@ -0,0 +1,13 @@ +use ohkami::prelude::*; + +#[tokio::main] +async fn main() { + Ohkami::new(( + "/" + .GET(|| async {Response::OK()}), + "/user" + .POST(|| async {Response::OK()}), + "/user/:id" + .GET(|id: String| async {id}), + )).howl("0.0.0.0:3000").await +} From edfd42ad92716c28ba242d22b1d9a2bf68d6b99d Mon Sep 17 00:00:00 2001 From: kanarus Date: Mon, 27 Jan 2025 05:06:26 +0900 Subject: [PATCH 4/4] remove `engines` --- rust/ohkami-nio/config.yaml | 2 -- rust/ohkami-tokio/config.yaml | 2 -- 2 files changed, 4 deletions(-) diff --git a/rust/ohkami-nio/config.yaml b/rust/ohkami-nio/config.yaml index efddff39729..567b9299287 100644 --- a/rust/ohkami-nio/config.yaml +++ b/rust/ohkami-nio/config.yaml @@ -1,5 +1,3 @@ framework: github: ohkami-rs/ohkami version: 0.21 - engines: - - nio diff --git a/rust/ohkami-tokio/config.yaml b/rust/ohkami-tokio/config.yaml index 8d5cfeeb421..567b9299287 100644 --- a/rust/ohkami-tokio/config.yaml +++ b/rust/ohkami-tokio/config.yaml @@ -1,5 +1,3 @@ framework: github: ohkami-rs/ohkami version: 0.21 - engines: - - tokio