Skip to content

Commit

Permalink
[xitca-web] update wasmtime. (TechEmpower#8419)
Browse files Browse the repository at this point in the history
* [xitca-web]update wasmtime.

* simplify router constructor.
  • Loading branch information
fakeshadow authored Sep 18, 2023
1 parent 4da046b commit e30b372
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 47 deletions.
2 changes: 1 addition & 1 deletion frameworks/Rust/xitca-web/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
56 changes: 28 additions & 28 deletions frameworks/Rust/xitca-web/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions frameworks/Rust/xitca-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
2 changes: 1 addition & 1 deletion frameworks/Rust/xitca-web/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2023-06-28"
channel = "nightly-2023-09-13"
6 changes: 3 additions & 3 deletions frameworks/Rust/xitca-web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -48,7 +48,7 @@ fn main() -> io::Result<()> {
})
})
.service(
Router::with_custom_object::<ContextObjectConstructor>()
Router::new()
.insert("/plaintext", get(fn_service(plain_text)))
.insert("/json", get(fn_service(json)))
.insert("/db", get(fn_service(db)))
Expand Down
20 changes: 14 additions & 6 deletions frameworks/Rust/xitca-web/xitca-web-wasm.dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
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
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

0 comments on commit e30b372

Please sign in to comment.