From 791c0341ce8ee35d8423cd0f37830c231b666576 Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:39:08 +0100 Subject: [PATCH] feat: remove syncwrapper from axum integration --- Cargo.lock | 1 - service/Cargo.toml | 3 +-- service/src/lib.rs | 12 +++++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25def720b9..7498f25b6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6469,7 +6469,6 @@ dependencies = [ "shuttle-codegen", "shuttle-common", "sqlx", - "sync_wrapper", "thiserror", "thruster", "tide", diff --git a/service/Cargo.toml b/service/Cargo.toml index 261d85514c..2379c1e4a9 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -31,7 +31,6 @@ salvo = { version = "0.37.5", optional = true } serde_json = { workspace = true } serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"], optional = true } poise = { version = "0.5.2", optional = true } -sync_wrapper = { version = "0.1.1", optional = true } thiserror = { workspace = true } thruster = { version = "1.3.0", optional = true } tide = { version = "0.16.0", optional = true } @@ -70,7 +69,7 @@ codegen = ["shuttle-codegen/frameworks"] loader = ["cargo", "libloading"] web-actix-web = ["actix-web", "num_cpus"] -web-axum = ["axum", "sync_wrapper"] +web-axum = ["axum"] web-rocket = ["rocket"] web-thruster = ["thruster"] web-tide = ["tide", "async-std"] diff --git a/service/src/lib.rs b/service/src/lib.rs index b6c09d93ca..d65961515e 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -540,12 +540,10 @@ pub type ShuttleWarp = Result, Error>; #[cfg(feature = "web-axum")] #[async_trait] -impl Service for sync_wrapper::SyncWrapper { +impl Service for axum::Router { async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { - let router = self.into_inner(); - axum::Server::bind(&addr) - .serve(router.into_make_service()) + .serve(self.into_make_service()) .await .map_err(error::CustomError::new)?; @@ -553,6 +551,9 @@ impl Service for sync_wrapper::SyncWrapper { } } +#[cfg(feature = "web-axum")] +pub type ShuttleAxum = Result; + #[cfg(feature = "web-actix-web")] #[async_trait] impl Service for F @@ -575,9 +576,6 @@ where #[cfg(feature = "web-actix-web")] pub type ShuttleActixWeb = Result; -#[cfg(feature = "web-axum")] -pub type ShuttleAxum = Result, Error>; - #[cfg(feature = "web-salvo")] #[async_trait] impl Service for salvo::Router {