diff --git a/frameworks/Rust/xitca-web/.cargo/config.toml b/frameworks/Rust/xitca-web/.cargo/config.toml index c3a0d915a90..bca4c6c1b26 100644 --- a/frameworks/Rust/xitca-web/.cargo/config.toml +++ b/frameworks/Rust/xitca-web/.cargo/config.toml @@ -2,5 +2,5 @@ rustflags = ["-C", "target-cpu=native"] incremental = false -[target.wasm32-wasi] +[target.wasm32-wasi-preview1-threads] rustflags = ["-C", "target-feature=+simd128", "--cfg", "tokio_unstable"] diff --git a/frameworks/Rust/xitca-web/Cargo.lock b/frameworks/Rust/xitca-web/Cargo.lock index ac25b29f505..28dc57413d9 100644 --- a/frameworks/Rust/xitca-web/Cargo.lock +++ b/frameworks/Rust/xitca-web/Cargo.lock @@ -49,9 +49,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bitflags" @@ -76,9 +76,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" @@ -259,9 +259,9 @@ checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libmimalloc-sys" @@ -399,9 +399,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -530,9 +530,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" dependencies = [ "itoa", "ryu", @@ -580,9 +580,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys", @@ -607,9 +607,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.31" +version = "2.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" +checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" dependencies = [ "proc-macro2", "quote", @@ -643,7 +643,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.4", "windows-sys", ] @@ -693,9 +693,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -809,7 +809,7 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "xitca-http" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" dependencies = [ "futures-core", "http", @@ -817,7 +817,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.3", + "socket2 0.5.4", "tokio", "tokio-uring", "tracing", @@ -830,7 +830,7 @@ dependencies = [ [[package]] name = "xitca-io" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" dependencies = [ "bytes", "tokio", @@ -841,7 +841,7 @@ dependencies = [ [[package]] name = "xitca-postgres" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" dependencies = [ "fallible-iterator", "percent-encoding", @@ -857,7 +857,7 @@ dependencies = [ [[package]] name = "xitca-router" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" dependencies = [ "xitca-unsafe-collection", ] @@ -865,9 +865,9 @@ dependencies = [ [[package]] name = "xitca-server" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" dependencies = [ - "socket2 0.5.3", + "socket2 0.5.4", "tokio", "tokio-uring", "tracing", @@ -879,12 +879,12 @@ dependencies = [ [[package]] name = "xitca-service" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" [[package]] name = "xitca-unsafe-collection" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" dependencies = [ "bytes", ] @@ -907,13 +907,13 @@ dependencies = [ "xitca-server", "xitca-service", "xitca-unsafe-collection", - "xitca-web 0.1.0 (git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c)", + "xitca-web 0.1.0 (git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9)", ] [[package]] name = "xitca-web" version = "0.1.0" -source = "git+https://github.com/HFQR/xitca-web.git?rev=1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c#1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" +source = "git+https://github.com/HFQR/xitca-web.git?rev=66a20d5fae8303918e0972798e85f55d1a5f97b9#66a20d5fae8303918e0972798e85f55d1a5f97b9" dependencies = [ "futures-core", "pin-project-lite", diff --git a/frameworks/Rust/xitca-web/Cargo.toml b/frameworks/Rust/xitca-web/Cargo.toml index 51aa9601c98..e571d236b6d 100644 --- a/frameworks/Rust/xitca-web/Cargo.toml +++ b/frameworks/Rust/xitca-web/Cargo.toml @@ -68,13 +68,13 @@ codegen-units = 1 panic = "abort" [patch.crates-io] -xitca-http = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } -xitca-io = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } -xitca-postgres = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } -xitca-router = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } -xitca-server = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } -xitca-service = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } -xitca-unsafe-collection = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } -xitca-web = { git = "https://github.com/HFQR/xitca-web.git", rev = "1a4e4e5917c1edc95de5f6fe38c6aabdc1bde66c" } +xitca-http = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } +xitca-io = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } +xitca-postgres = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } +xitca-router = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } +xitca-server = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } +xitca-service = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } +xitca-unsafe-collection = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } +xitca-web = { git = "https://github.com/HFQR/xitca-web.git", rev = "66a20d5fae8303918e0972798e85f55d1a5f97b9" } mio = { git = "https://github.com/fakeshadow/mio.git", rev = "eb67f6794edba8bc2e973ddef32e066b41ff812a" } diff --git a/frameworks/Rust/xitca-web/rust-toolchain.toml b/frameworks/Rust/xitca-web/rust-toolchain.toml index 6907ae28bf7..31929824cff 100644 --- a/frameworks/Rust/xitca-web/rust-toolchain.toml +++ b/frameworks/Rust/xitca-web/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2023-06-28" +channel = "nightly-2023-09-13" diff --git a/frameworks/Rust/xitca-web/src/main.rs b/frameworks/Rust/xitca-web/src/main.rs index 4fca1962ab8..2297f8a30b9 100755 --- a/frameworks/Rust/xitca-web/src/main.rs +++ b/frameworks/Rust/xitca-web/src/main.rs @@ -19,9 +19,9 @@ use xitca_http::{ IntoResponse, RequestExt, }, util::service::{ - context::{object::ContextObjectConstructor, Context, ContextBuilder}, + context::{Context, ContextBuilder}, route::get, - Router, + router::Router, }, HttpServiceBuilder, }; @@ -48,7 +48,7 @@ fn main() -> io::Result<()> { }) }) .service( - Router::with_custom_object::() + Router::new() .insert("/plaintext", get(fn_service(plain_text))) .insert("/json", get(fn_service(json))) .insert("/db", get(fn_service(db))) diff --git a/frameworks/Rust/xitca-web/xitca-web-wasm.dockerfile b/frameworks/Rust/xitca-web/xitca-web-wasm.dockerfile index e18e19c7fb3..c44aa9cf8dc 100644 --- a/frameworks/Rust/xitca-web/xitca-web-wasm.dockerfile +++ b/frameworks/Rust/xitca-web/xitca-web-wasm.dockerfile @@ -1,18 +1,25 @@ +ARG WASMTIME_VERSION=12.0.1 +ARG WASM_TARGET=wasm32-wasi-preview1-threads + FROM rust:1.67 AS compile -ARG WASMTIME_VERSION=11.0.1 +ARG WASMTIME_VERSION +ARG WASM_TARGET WORKDIR /tmp COPY / ./ RUN curl -LSs "https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-$(uname -m)-linux.tar.xz" | \ tar --strip-components=1 -Jx && \ -rustup target add wasm32-wasi && \ -cargo build --bin xitca-web-wasm --features serde,web --release --target wasm32-wasi +rustup target add ${WASM_TARGET} && \ +cargo build --bin xitca-web-wasm --features serde,web --release --target ${WASM_TARGET} + FROM ubuntu:22.04 +ARG WASM_TARGET + COPY --from=compile \ -/tmp/target/wasm32-wasi/release/xitca-web-wasm.wasm \ +/tmp/target/${WASM_TARGET}/release/xitca-web-wasm.wasm \ /tmp/wasmtime \ /opt/xitca-web-wasm/ EXPOSE 8080 @@ -20,8 +27,9 @@ ARG BENCHMARK_ENV ARG TFB_TEST_DATABASE ARG TFB_TEST_NAME -CMD /opt/xitca-web-wasm/wasmtime compile /opt/xitca-web-wasm/xitca-web-wasm.wasm && \ -/opt/xitca-web-wasm/wasmtime run xitca-web-wasm.cwasm \ +CMD /opt/xitca-web-wasm/wasmtime run /opt/xitca-web-wasm/xitca-web-wasm.wasm \ +--wasm-features=threads \ +--wasi-modules experimental-wasi-threads \ --allow-precompiled \ --env FD_COUNT=3 \ --tcplisten 0.0.0.0:8080