From 0c28b83dc78471f820161b7540b08d958f6593a4 Mon Sep 17 00:00:00 2001 From: chesedo Date: Thu, 12 Jan 2023 10:12:14 +0200 Subject: [PATCH 1/6] feat: shuttle-next crate for better DX --- Cargo.lock | 14 +++++++++++ Cargo.toml | 1 + codegen/src/next/mod.rs | 42 +++++++++++++++---------------- next/Cargo.toml | 27 ++++++++++++++++++++ next/src/lib.rs | 8 ++++++ tmp/axum-wasm-expanded/Cargo.toml | 14 +---------- tmp/axum-wasm-expanded/src/lib.rs | 40 ++++++++++++++--------------- tmp/axum-wasm/Cargo.toml | 20 +-------------- tmp/axum-wasm/src/lib.rs | 2 +- 9 files changed, 94 insertions(+), 74 deletions(-) create mode 100644 next/Cargo.toml create mode 100644 next/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index ff2cff0bd..ad7677c4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6344,6 +6344,20 @@ dependencies = [ "uuid 1.2.2", ] +[[package]] +name = "shuttle-next" +version = "0.8.0" +dependencies = [ + "axum", + "futures-executor", + "http 0.2.8", + "rmp-serde", + "shuttle-codegen", + "shuttle-common", + "tower-service", + "tracing-subscriber", +] + [[package]] name = "shuttle-proto" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index 483679463..482a3562d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "common", "deployer", "gateway", + "next", "proto", "provisioner", "runtime", diff --git a/codegen/src/next/mod.rs b/codegen/src/next/mod.rs index f91c19928..3c0f93b3e 100644 --- a/codegen/src/next/mod.rs +++ b/codegen/src/next/mod.rs @@ -203,7 +203,7 @@ impl ToTokens for Endpoint { } }; - let route = quote!(.route(#route, axum::routing::#method(#function))); + let route = quote!(.route(#route, shuttle_next::routing::#method(#function))); route.to_tokens(tokens); } @@ -238,11 +238,11 @@ impl ToTokens for App { let Self { endpoints } = self; let app = quote!( - async fn __app(request: http::Request,) -> axum::response::Response + async fn __app(request: shuttle_next::Request,) -> shuttle_next::response::Response { - use tower_service::Service; + use shuttle_next::Service; - let mut router = axum::Router::new() + let mut router = shuttle_next::Router::new() #(#endpoints)*; let response = router.call(request).await.unwrap(); @@ -267,18 +267,18 @@ pub(crate) fn wasi_bindings(app: App) -> proc_macro2::TokenStream { body_read_fd: std::os::wasi::prelude::RawFd, body_write_fd: std::os::wasi::prelude::RawFd, ) { - use axum::body::HttpBody; - use shuttle_common::wasm::Logger; + use shuttle_next::body::{Body, HttpBody}; + use shuttle_next::tracing_prelude::*; + use shuttle_next::Logger; use std::io::{Read, Write}; use std::os::wasi::io::FromRawFd; - use tracing_subscriber::prelude::*; println!("inner handler awoken; interacting with fd={},{},{},{}", logs_fd, parts_fd, body_read_fd, body_write_fd); // file descriptor 2 for writing logs to let logs_fd = unsafe { std::fs::File::from_raw_fd(logs_fd) }; - tracing_subscriber::registry() + shuttle_next::tracing_registry() .with(Logger::new(logs_fd)) .init(); // this sets the subscriber as the global default and also adds a compatibility layer for capturing `log::Record`s @@ -288,7 +288,7 @@ pub(crate) fn wasi_bindings(app: App) -> proc_macro2::TokenStream { let reader = std::io::BufReader::new(&mut parts_fd); // deserialize request parts from rust messagepack - let wrapper: shuttle_common::wasm::RequestWrapper = rmp_serde::from_read(reader).unwrap(); + let wrapper: shuttle_next::RequestWrapper = shuttle_next::from_read(reader).unwrap(); // file descriptor 4 for reading http body into wasm let mut body_read_stream = unsafe { std::fs::File::from_raw_fd(body_read_fd) }; @@ -297,20 +297,20 @@ pub(crate) fn wasi_bindings(app: App) -> proc_macro2::TokenStream { let mut body_buf = Vec::new(); reader.read_to_end(&mut body_buf).unwrap(); - let body = axum::body::Body::from(body_buf); + let body = Body::from(body_buf); let request = wrapper .into_request_builder() - .body(axum::body::boxed(body)) + .body(shuttle_next::body::boxed(body)) .unwrap(); println!("inner router received request: {:?}", &request); - let res = futures_executor::block_on(__app(request)); + let res = shuttle_next::block_on(__app(request)); let (parts, mut body) = res.into_parts(); // wrap and serialize response parts as rmp - let response_parts = shuttle_common::wasm::ResponseWrapper::from(parts).into_rmp(); + let response_parts = shuttle_next::ResponseWrapper::from(parts).into_rmp(); // write response parts parts_fd.write_all(&response_parts).unwrap(); @@ -319,7 +319,7 @@ pub(crate) fn wasi_bindings(app: App) -> proc_macro2::TokenStream { let mut body_write_stream = unsafe { std::fs::File::from_raw_fd(body_write_fd) }; // write body if there is one - if let Some(body) = futures_executor::block_on(body.data()) { + if let Some(body) = shuttle_next::block_on(body.data()) { body_write_stream.write_all(body.unwrap().as_ref()).unwrap(); } } @@ -345,7 +345,7 @@ mod tests { }; let actual = quote!(#endpoint); - let expected = quote!(.route("/hello", axum::routing::get(hello))); + let expected = quote!(.route("/hello", shuttle_next::routing::get(hello))); assert_eq!(actual.to_string(), expected.to_string()); } @@ -370,13 +370,13 @@ mod tests { let actual = quote!(#app); let expected = quote!( async fn __app( - request: http::Request, - ) -> axum::response::Response { - use tower_service::Service; + request: shuttle_next::Request, + ) -> shuttle_next::response::Response { + use shuttle_next::Service; - let mut router = axum::Router::new() - .route("/hello", axum::routing::get(hello)) - .route("/goodbye", axum::routing::post(goodbye)); + let mut router = shuttle_next::Router::new() + .route("/hello", shuttle_next::routing::get(hello)) + .route("/goodbye", shuttle_next::routing::post(goodbye)); let response = router.call(request).await.unwrap(); diff --git a/next/Cargo.toml b/next/Cargo.toml new file mode 100644 index 000000000..bf1daa508 --- /dev/null +++ b/next/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "shuttle-next" +version = "0.8.0" +edition.workspace = true +license.workspace = true +description = "Macros and aliases to deploy wasm on the shuttle platform (https://www.shuttle.rs/)" +homepage = "https://www.shuttle.rs" + +[lib] + +[dependencies] +# most axum features can be enabled, but "tokio" and "ws" depend on socket2 +# via "hyper/tcp" which is not compatible with wasi +axum = { version = "0.6.0", default-features = false } +futures-executor = "0.3.21" +http = "0.2.7" +rmp-serde = "1.1.1" +tower-service = "0.3.1" +tracing-subscriber = "0.3.16" + +[dependencies.shuttle-codegen] +workspace = true +features = ["next"] + +[dependencies.shuttle-common] +workspace = true +features = ["wasm"] diff --git a/next/src/lib.rs b/next/src/lib.rs new file mode 100644 index 000000000..a53c79c79 --- /dev/null +++ b/next/src/lib.rs @@ -0,0 +1,8 @@ +pub use axum::*; +pub use futures_executor::block_on; +pub use http::Request; +pub use rmp_serde::from_read; +pub use shuttle_codegen::app; +pub use shuttle_common::wasm::{Logger, RequestWrapper, ResponseWrapper}; +pub use tower_service::Service; +pub use tracing_subscriber::{prelude as tracing_prelude, registry as tracing_registry}; diff --git a/tmp/axum-wasm-expanded/Cargo.toml b/tmp/axum-wasm-expanded/Cargo.toml index 81cc6ad1c..b0aab9207 100644 --- a/tmp/axum-wasm-expanded/Cargo.toml +++ b/tmp/axum-wasm-expanded/Cargo.toml @@ -7,18 +7,6 @@ edition = "2021" crate-type = [ "cdylib" ] [dependencies] -# most axum features can be enabled, but "tokio" and "ws" depend on socket2 -# via "hyper/tcp" which is not compatible with wasi -axum = { version = "0.6.0", default-features = false } futures = "0.3.25" -futures-executor = "0.3.21" -http = "0.2.7" -tower-service = "0.3.1" -rmp-serde = { version = "1.1.1" } +shuttle-next = "0.8.0" tracing = "0.1.37" -tracing-subscriber = "0.3.16" - -[dependencies.shuttle-common] -path = "../../common" -features = ["wasm"] -version = "0.8.0" diff --git a/tmp/axum-wasm-expanded/src/lib.rs b/tmp/axum-wasm-expanded/src/lib.rs index a15b022a1..84d1b8569 100644 --- a/tmp/axum-wasm-expanded/src/lib.rs +++ b/tmp/axum-wasm-expanded/src/lib.rs @@ -1,22 +1,22 @@ -use axum::{ +use futures::TryStreamExt; +use shuttle_next::{ body::BoxBody, extract::BodyStream, response::{IntoResponse, Response}, }; -use futures::TryStreamExt; use tracing::debug; -pub fn handle_request(req: http::Request) -> axum::response::Response { - futures_executor::block_on(app(req)) +pub fn handle_request(req: shuttle_next::Request) -> shuttle_next::response::Response { + shuttle_next::block_on(app(req)) } -async fn app(request: http::Request) -> axum::response::Response { - use tower_service::Service; +async fn app(request: shuttle_next::Request) -> shuttle_next::response::Response { + use shuttle_next::Service; - let mut router = axum::Router::new() - .route("/hello", axum::routing::get(hello)) - .route("/goodbye", axum::routing::get(goodbye)) - .route("/uppercase", axum::routing::post(uppercase)); + let mut router = shuttle_next::Router::new() + .route("/hello", shuttle_next::routing::get(hello)) + .route("/goodbye", shuttle_next::routing::get(goodbye)) + .route("/uppercase", shuttle_next::routing::post(uppercase)); let response = router.call(request).await.unwrap(); @@ -42,7 +42,7 @@ async fn uppercase(body: BodyStream) -> impl IntoResponse { .map(|byte| byte.to_ascii_uppercase()) .collect::>() }); - Response::new(axum::body::StreamBody::new(chunk_stream)) + Response::new(shuttle_next::body::StreamBody::new(chunk_stream)) } #[no_mangle] @@ -53,18 +53,18 @@ pub extern "C" fn __SHUTTLE_Axum_call( body_read_fd: std::os::wasi::prelude::RawFd, body_write_fd: std::os::wasi::prelude::RawFd, ) { - use axum::body::HttpBody; - use shuttle_common::wasm::Logger; + use shuttle_next::body::{Body, HttpBody}; + use shuttle_next::tracing_prelude::*; + use shuttle_next::Logger; use std::io::{Read, Write}; use std::os::wasi::io::FromRawFd; - use tracing_subscriber::prelude::*; println!("inner handler awoken; interacting with fd={logs_fd},{parts_fd},{body_read_fd},{body_write_fd}"); // file descriptor 2 for writing logs to let logs_fd = unsafe { std::fs::File::from_raw_fd(logs_fd) }; - tracing_subscriber::registry() + shuttle_next::tracing_registry() .with(Logger::new(logs_fd)) .init(); // this sets the subscriber as the global default and also adds a compatibility layer for capturing `log::Record`s @@ -74,7 +74,7 @@ pub extern "C" fn __SHUTTLE_Axum_call( let reader = std::io::BufReader::new(&mut parts_fd); // deserialize request parts from rust messagepack - let wrapper: shuttle_common::wasm::RequestWrapper = rmp_serde::from_read(reader).unwrap(); + let wrapper: shuttle_next::RequestWrapper = shuttle_next::from_read(reader).unwrap(); // file descriptor 4 for reading http body into wasm let mut body_read_stream = unsafe { std::fs::File::from_raw_fd(body_read_fd) }; @@ -83,11 +83,11 @@ pub extern "C" fn __SHUTTLE_Axum_call( let mut body_buf = Vec::new(); reader.read_to_end(&mut body_buf).unwrap(); - let body = axum::body::Body::from(body_buf); + let body = Body::from(body_buf); let request = wrapper .into_request_builder() - .body(axum::body::boxed(body)) + .body(shuttle_next::body::boxed(body)) .unwrap(); println!("inner router received request: {:?}", &request); @@ -96,7 +96,7 @@ pub extern "C" fn __SHUTTLE_Axum_call( let (parts, mut body) = res.into_parts(); // wrap and serialize response parts as rmp - let response_parts = shuttle_common::wasm::ResponseWrapper::from(parts).into_rmp(); + let response_parts = shuttle_next::ResponseWrapper::from(parts).into_rmp(); // write response parts parts_fd.write_all(&response_parts).unwrap(); @@ -105,7 +105,7 @@ pub extern "C" fn __SHUTTLE_Axum_call( let mut body_write_stream = unsafe { std::fs::File::from_raw_fd(body_write_fd) }; // write body if there is one - if let Some(body) = futures_executor::block_on(body.data()) { + if let Some(body) = shuttle_next::block_on(body.data()) { body_write_stream.write_all(body.unwrap().as_ref()).unwrap(); } } diff --git a/tmp/axum-wasm/Cargo.toml b/tmp/axum-wasm/Cargo.toml index 07b361e91..341c6524f 100644 --- a/tmp/axum-wasm/Cargo.toml +++ b/tmp/axum-wasm/Cargo.toml @@ -7,23 +7,5 @@ edition = "2021" crate-type = [ "cdylib" ] [dependencies] -# most axum features can be enabled, but "tokio" and "ws" depend on socket2 -# via "hyper/tcp" which is not compatible with wasi -axum = { version = "0.6.0", default-features = false } -futures-executor = "0.3.21" -futures = "0.3.25" -http = "0.2.7" -tower-service = "0.3.1" -rmp-serde = { version = "1.1.1" } +shuttle-next = "0.8.0" tracing = "0.1.37" -tracing-subscriber = "0.3.16" - -[dependencies.shuttle-codegen] -path = "../../codegen" -features = ["next"] -version = "0.8.0" - -[dependencies.shuttle-common] -path = "../../common" -features = ["wasm"] -version = "0.8.0" diff --git a/tmp/axum-wasm/src/lib.rs b/tmp/axum-wasm/src/lib.rs index b4620386a..d069e1539 100644 --- a/tmp/axum-wasm/src/lib.rs +++ b/tmp/axum-wasm/src/lib.rs @@ -1,6 +1,6 @@ use tracing::debug; -shuttle_codegen::app! { +shuttle_next::app! { #[shuttle_codegen::endpoint(method = get, route = "/hello")] async fn hello() -> &'static str { debug!("called hello()"); From a766e0b03c57d45f3709e9f974a0f1e9b00f422f Mon Sep 17 00:00:00 2001 From: chesedo Date: Thu, 12 Jan 2023 13:05:13 +0200 Subject: [PATCH 2/6] refactor: trim dependencies --- Cargo.lock | 4 ++-- Cargo.toml | 10 +++++----- cargo-shuttle/Cargo.toml | 2 +- common/Cargo.toml | 15 ++++++++------- common/src/lib.rs | 9 +++++++++ gateway/Cargo.toml | 2 +- next/Cargo.toml | 4 ++-- proto/Cargo.toml | 2 +- runtime/Cargo.toml | 2 +- service/Cargo.toml | 2 +- 10 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad7677c4c..42b9b445d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6023,9 +6023,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "184c643044780f7ceb59104cef98a5a6f12cb2288a7bc701ab93a362b49fd47d" +checksum = "26b04f22b563c91331a10074bda3dd5492e3cc39d56bd557e91c0af42b6c7341" dependencies = [ "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 482a3562d..c58f1d94e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,13 +38,13 @@ shuttle-service = { path = "service", version = "0.8.0" } anyhow = "1.0.66" async-trait = "0.1.58" -axum = "0.6.0" -chrono = "0.4.23" +axum = { version = "0.6.0", default-features = false } +chrono = { version = "0.4.23", default-features = false, features = ["clock"] } once_cell = "1.16.0" uuid = "1.2.2" thiserror = "1.0.37" -serde = "1.0.148" +serde = { version = "1.0.148", default-features = false } serde_json = "1.0.89" tonic = "0.8.3" -tracing = "0.1.37" -tracing-subscriber = "0.3.16" +tracing = { version = "0.1.37", default-features = false } +tracing-subscriber = { version = "0.3.16", default-features = false, features = ["registry", "std"] } diff --git a/cargo-shuttle/Cargo.toml b/cargo-shuttle/Cargo.toml index 865cd4e67..4d484c8e3 100644 --- a/cargo-shuttle/Cargo.toml +++ b/cargo-shuttle/Cargo.toml @@ -45,7 +45,7 @@ toml = "0.5.9" toml_edit = "0.15.0" tonic = { workspace = true } tracing = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } url = "2.3.1" uuid = { workspace = true, features = ["v4"] } webbrowser = "0.8.2" diff --git a/common/Cargo.toml b/common/Cargo.toml index e3e90ddb8..47db8aa75 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -10,21 +10,21 @@ description = "Common library for the shuttle platform (https://www.shuttle.rs/) anyhow = { workspace = true, optional = true } async-trait = { workspace = true , optional = true } axum = { workspace = true, optional = true } -chrono = { workspace = true, features = ["serde"] } +chrono = { workspace = true } comfy-table = { version = "6.1.3", optional = true } crossterm = { version = "0.25.0", optional = true } http = { version = "0.2.8", optional = true } http-serde = { version = "1.1.2", optional = true } -once_cell = { workspace = true } +once_cell = { workspace = true, optional = true } reqwest = { version = "0.11.13", optional = true } rmp-serde = { version = "1.1.1", optional = true } -rustrict = "0.5.5" -serde = { workspace = true, features = ["derive"] } +rustrict = { version = "0.5.5", optional = true } +serde = { workspace = true } serde_json = { workspace = true, optional = true } -strum = { version = "0.24.1", features = ["derive"] } +strum = { version = "0.24.1", features = ["derive"], optional = true } tracing = { workspace = true } tracing-subscriber = { workspace = true, optional = true } -uuid = { workspace = true, features = ["v4", "serde"] } +uuid = { workspace = true, features = ["v4", "serde"], optional = true } [dev-dependencies] cap-std = "1.0.2" @@ -35,4 +35,5 @@ backend = ["async-trait", "axum"] display = ["comfy-table", "crossterm"] tracing = ["serde_json"] wasm = ["http-serde", "http", "rmp-serde", "tracing", "tracing-subscriber"] -models = ["anyhow", "async-trait", "display", "http", "reqwest", "serde_json"] +models = ["anyhow", "async-trait", "display", "http", "reqwest", "serde_json", "service"] +service = ["chrono/serde", "once_cell", "rustrict", "serde/derive", "strum", "uuid"] diff --git a/common/src/lib.rs b/common/src/lib.rs index 2c037786e..11d3741c1 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,11 +1,16 @@ #[cfg(feature = "backend")] pub mod backends; +#[cfg(feature = "service")] pub mod database; +#[cfg(feature = "service")] pub mod deployment; +#[cfg(feature = "service")] pub mod log; #[cfg(feature = "models")] pub mod models; +#[cfg(feature = "service")] pub mod project; +#[cfg(feature = "service")] pub mod storage_manager; #[cfg(feature = "tracing")] pub mod tracing; @@ -13,9 +18,12 @@ pub mod tracing; pub mod wasm; use serde::{Deserialize, Serialize}; +#[cfg(feature = "service")] use uuid::Uuid; +#[cfg(feature = "service")] pub use log::Item as LogItem; +#[cfg(feature = "service")] pub use log::STATE_MESSAGE; #[cfg(debug_assertions)] @@ -27,6 +35,7 @@ pub const API_URL_DEFAULT: &str = "https://api.shuttle.rs"; pub type ApiKey = String; pub type ApiUrl = String; pub type Host = String; +#[cfg(feature = "service")] pub type DeploymentId = Uuid; #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 932b2e7a8..46623e80f 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] acme2 = "0.5.1" async-trait = { workspace = true } -axum = { workspace = true, features = [ "headers" ] } +axum = { workspace = true, features = [ "default", "headers" ] } axum-server = { version = "0.4.4", features = [ "tls-rustls" ] } base64 = "0.13.1" bollard = "0.13.0" diff --git a/next/Cargo.toml b/next/Cargo.toml index bf1daa508..214eaed0e 100644 --- a/next/Cargo.toml +++ b/next/Cargo.toml @@ -11,12 +11,12 @@ homepage = "https://www.shuttle.rs" [dependencies] # most axum features can be enabled, but "tokio" and "ws" depend on socket2 # via "hyper/tcp" which is not compatible with wasi -axum = { version = "0.6.0", default-features = false } +axum = { workspace = true } futures-executor = "0.3.21" http = "0.2.7" rmp-serde = "1.1.1" tower-service = "0.3.1" -tracing-subscriber = "0.3.16" +tracing-subscriber = { workspace = true } [dependencies.shuttle-codegen] workspace = true diff --git a/proto/Cargo.toml b/proto/Cargo.toml index ab998ffa0..bc1680850 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -18,7 +18,7 @@ uuid = { workspace = true, features = ["v4"] } [dependencies.shuttle-common] workspace = true -features = ["models", "wasm"] +features = ["models", "service", "wasm"] [build-dependencies] tonic-build = "0.8.3" diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index adee32637..d57b96596 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -18,7 +18,7 @@ tokio = { version = "=1.22.0", features = ["full"] } tokio-stream = "0.1.11" tonic = { workspace = true } tracing = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } uuid = { workspace = true, features = ["v4"] } wasi-common = "4.0.0" wasmtime = "4.0.0" diff --git a/service/Cargo.toml b/service/Cargo.toml index b829619c9..261d85514 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -55,7 +55,7 @@ optional = true [dependencies.shuttle-common] workspace = true -features = ["tracing"] +features = ["tracing", "service"] [dev-dependencies] portpicker = "0.1.1" From b3c9ad0ac52e90a09d4e3e48e9fd79114aaf53d8 Mon Sep 17 00:00:00 2001 From: chesedo Date: Thu, 12 Jan 2023 13:12:43 +0200 Subject: [PATCH 3/6] bug: fix next check --- service/src/lib.rs | 1 + service/src/loader.rs | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/service/src/lib.rs b/service/src/lib.rs index 66e673e05..2ece4b571 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -680,3 +680,4 @@ pub type ShuttlePoise = Result>, Err pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const NAME: &str = env!("CARGO_PKG_NAME"); +pub const NEXT_NAME: &str = "shuttle-next"; diff --git a/service/src/loader.rs b/service/src/loader.rs index 19d1114c3..98f42db29 100644 --- a/service/src/loader.rs +++ b/service/src/loader.rs @@ -22,7 +22,7 @@ use futures::FutureExt; use uuid::Uuid; use crate::error::CustomError; -use crate::{logger, Bootstrapper, NAME, VERSION}; +use crate::{logger, Bootstrapper, NAME, NEXT_NAME, VERSION}; use crate::{Error, Factory, ServeHandle}; const ENTRYPOINT_SYMBOL_NAME: &[u8] = b"_create_service\0"; @@ -296,17 +296,10 @@ fn make_name_unique(summary: &mut Summary, deployment_id: Uuid) { } fn is_next(summary: &Summary) -> bool { - let features = if let Some(shuttle) = summary + summary .dependencies() .iter() - .find(|dependency| dependency.package_name() == "shuttle-codegen") - { - shuttle.features() - } else { - &[] - }; - - features.contains(&InternedString::new("next")) + .any(|dependency| dependency.package_name() == NEXT_NAME) } /// Check that the crate being build is compatible with this version of loader From 8eefb4631271935a6ed51b44afbdd7670dcbd7eb Mon Sep 17 00:00:00 2001 From: chesedo Date: Thu, 12 Jan 2023 13:16:40 +0200 Subject: [PATCH 4/6] ci: add shuttle-runtime --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e9650676..d14ee3eca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -405,7 +405,7 @@ workflows: - workspace-clippy matrix: parameters: - crate: ["shuttle-deployer", "cargo-shuttle", "shuttle-codegen", "shuttle-common", "shuttle-proto", "shuttle-provisioner"] + crate: ["shuttle-deployer", "cargo-shuttle", "shuttle-codegen", "shuttle-common", "shuttle-proto", "shuttle-provisioner", "shuttle-runtime"] - e2e-test: requires: - service-test From 7dd9ee31d85cd7d93271bd4c3415e7cef09f0e96 Mon Sep 17 00:00:00 2001 From: chesedo Date: Thu, 12 Jan 2023 14:06:46 +0200 Subject: [PATCH 5/6] refactor: activating missing features on dependencies --- deployer/Cargo.toml | 4 ++-- provisioner/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deployer/Cargo.toml b/deployer/Cargo.toml index 71e9fa3b4..21672f357 100644 --- a/deployer/Cargo.toml +++ b/deployer/Cargo.toml @@ -8,7 +8,7 @@ description = "Service with instances created per project for handling the compi [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -axum = { workspace = true, features = ["ws"] } +axum = { workspace = true, features = ["default", "ws"] } bytes = "1.3.0" # TODO: debug the libgit2-sys conflict with cargo-edit when upgrading cargo to 0.66 cargo = "0.65.0" @@ -41,7 +41,7 @@ tower = { version = "0.4.13", features = ["make"] } tower-http = { version = "0.3.4", features = ["auth", "trace"] } tracing = { workspace = true } tracing-opentelemetry = "0.18.0" -tracing-subscriber = { workspace = true, features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } uuid = { workspace = true, features = ["v4"] } [dependencies.shuttle-common] diff --git a/provisioner/Cargo.toml b/provisioner/Cargo.toml index 1ce62ca7b..02b1b8f50 100644 --- a/provisioner/Cargo.toml +++ b/provisioner/Cargo.toml @@ -20,7 +20,7 @@ thiserror = { workspace = true } tokio = { version = "1.22.0", features = ["macros", "rt-multi-thread"] } tonic = { workspace = true } tracing = { workspace = true } -tracing-subscriber = { workspace = true } +tracing-subscriber = { workspace = true, features = ["fmt"] } [dependencies.shuttle-proto] workspace = true From 4056a18ff1b6697237d394b3f71f114eae9e7ea5 Mon Sep 17 00:00:00 2001 From: chesedo Date: Thu, 12 Jan 2023 14:08:24 +0200 Subject: [PATCH 6/6] refactor: update to shuttle_next::endpoint --- tmp/axum-wasm/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmp/axum-wasm/src/lib.rs b/tmp/axum-wasm/src/lib.rs index d069e1539..a6af35583 100644 --- a/tmp/axum-wasm/src/lib.rs +++ b/tmp/axum-wasm/src/lib.rs @@ -1,13 +1,13 @@ use tracing::debug; shuttle_next::app! { - #[shuttle_codegen::endpoint(method = get, route = "/hello")] + #[shuttle_next::endpoint(method = get, route = "/hello")] async fn hello() -> &'static str { debug!("called hello()"); "Hello, World!" } - #[shuttle_codegen::endpoint(method = get, route = "/goodbye")] + #[shuttle_next::endpoint(method = get, route = "/goodbye")] async fn goodbye() -> &'static str { debug!("called goodbye()"); "Goodbye, World!"