diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..c20090b --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "wasm32-wasi" +rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"] diff --git a/Cargo.toml b/Cargo.toml index c377595..049edb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,18 @@ name = "order_demo_service" version = "0.1.0" edition = "2021" +[patch.crates-io] +tokio = { git = "https://github.com/second-state/wasi_tokio.git", branch = "v1.36.x" } +socket2 = { git = "https://github.com/second-state/socket2.git", branch = "v0.5.x" } +hyper = { git = "https://github.com/second-state/wasi_hyper.git", branch = "v0.14.x" } + [dependencies] anyhow = "1.0" serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } url = "2.3" -mysql_async_wasi = "=0.31.5" -hyper_wasi = { version = "0.15", features = ["full"] } -tokio_wasi = { version = "1", features = ["io-util", "fs", "net", "time", "rt", "macros"] } \ No newline at end of file + +mysql_async = { version = "0.34", default-features=false, features = [ "default-rustls" ], git="https://github.com/blackbeam/mysql_async.git" } +zstd-sys = "=2.0.9" +hyper = { version = "0.14", features = ["full"] } +tokio = { version = "1", features = ["io-util", "fs", "net", "time", "rt", "macros"] } diff --git a/src/main.rs b/src/main.rs index 309a329..db6e16d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,6 +225,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { let pool = Pool::new(builder.pool_opts(pool_opts)); let addr = SocketAddr::from(([0, 0, 0, 0], 8080)); + let tcp_listener = tokio::net::TcpListener::bind(addr).await.unwrap(); let make_svc = make_service_fn(|_| { let pool = pool.clone(); async move { @@ -234,7 +235,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { })) } }); - let server = Server::bind(&addr).serve(make_svc); + let server = Server::from_tcp(tcp_listener.into_std().unwrap()).unwrap().serve(make_svc); if let Err(e) = server.await { eprintln!("server error: {}", e); }