From d7c3c21720e2d4cf7ebe1a0a5a4a1b0b3ce5a8c3 Mon Sep 17 00:00:00 2001 From: Eguo Wang Date: Sat, 2 Dec 2023 19:48:23 +0800 Subject: [PATCH] Upgrade axum to 0.7.1 --- Cargo.lock | 163 ++++++++++++++++++++++++++----------------- Cargo.toml | 4 +- apiserver/Cargo.toml | 6 +- apiserver/src/app.rs | 12 ++-- 4 files changed, 109 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b724fa8..83d4134 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,7 +61,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "amp-apiserver" -version = "0.6.9" +version = "0.6.10" dependencies = [ "amp-common", "amp-resources", @@ -72,7 +72,7 @@ dependencies = [ "clap", "dotenv", "futures", - "headers 0.4.0", + "headers", "k8s-openapi", "kube", "serde", @@ -93,8 +93,8 @@ dependencies = [ [[package]] name = "amp-common" -version = "0.5.5" -source = "git+https://github.com/amphitheatre-app/common?tag=v0.5.5#07468972db0ab9bf1873f8744fb9b3fb1a5cd3b6" +version = "0.5.6" +source = "git+https://github.com/amphitheatre-app/common?tag=v0.5.6#fe105fa92a5d1e41b5c6b59fe5f91fcb4537ca0a" dependencies = [ "anyhow", "chrono", @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "amp-controllers" -version = "0.6.9" +version = "0.6.10" dependencies = [ "amp-common", "amp-resolver", @@ -146,7 +146,7 @@ dependencies = [ [[package]] name = "amp-crdgen" -version = "0.6.9" +version = "0.6.10" dependencies = [ "amp-common", "clap", @@ -158,7 +158,7 @@ dependencies = [ [[package]] name = "amp-resolver" -version = "0.6.9" +version = "0.6.10" dependencies = [ "amp-common", "amp-resources", @@ -172,7 +172,7 @@ dependencies = [ [[package]] name = "amp-resources" -version = "0.6.9" +version = "0.6.10" dependencies = [ "amp-common", "anyhow", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "amp-syncer" -version = "0.6.9" +version = "0.6.10" dependencies = [ "amp-common", "async-nats", @@ -345,19 +345,19 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "810a80b128d70e6ed2bdf3fe8ed72c0ae56f5f5948d01c2753282dd92a84fce8" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "headers 0.3.9", - "http 0.2.9", - "http-body 0.4.5", - "hyper", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.0.1", + "hyper-util", "itoa", "matchit", "memchr", @@ -378,17 +378,20 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "de0ddc355eab88f4955090a823715df47acf0b7660aab7a69ad5ce6301ee3b73" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.9", - "http-body 0.4.5", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -1090,6 +1093,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap 2.0.2", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1116,21 +1138,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "headers" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" -dependencies = [ - "base64 0.21.4", - "bytes", - "headers-core 0.2.0", - "http 0.2.9", - "httpdate", - "mime", - "sha1", -] - [[package]] name = "headers" version = "0.4.0" @@ -1139,22 +1146,13 @@ checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" dependencies = [ "base64 0.21.4", "bytes", - "headers-core 0.3.0", + "headers-core", "http 1.0.0", "httpdate", "mime", "sha1", ] -[[package]] -name = "headers-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" -dependencies = [ - "http 0.2.9", -] - [[package]] name = "headers-core" version = "0.3.0" @@ -1293,7 +1291,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.21", "http 0.2.9", "http-body 0.4.5", "httparse", @@ -1307,6 +1305,25 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f9214f3e703236b221f1a9cd88ec8b4adfa5296de01ab96216361f4692f56" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.0", + "http 1.0.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", +] + [[package]] name = "hyper-rustls" version = "0.24.1" @@ -1315,7 +1332,7 @@ checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ "futures-util", "http 0.2.9", - "hyper", + "hyper 0.14.27", "log", "rustls", "rustls-native-certs", @@ -1329,12 +1346,32 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.27", "pin-project-lite", "tokio", "tokio-io-timeout", ] +[[package]] +name = "hyper-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca339002caeb0d159cc6e023dff48e199f081e42fa039895c7c6f38b37f2e9d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.0.1", + "pin-project-lite", + "socket2 0.5.5", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.57" @@ -1588,7 +1625,7 @@ dependencies = [ "home", "http 0.2.9", "http-body 0.4.5", - "hyper", + "hyper 0.14.27", "hyper-rustls", "hyper-timeout", "jsonpath_lib", @@ -2183,10 +2220,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.21", "http 0.2.9", "http-body 0.4.5", - "hyper", + "hyper 0.14.27", "hyper-rustls", "ipnet", "js-sys", @@ -2245,9 +2282,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "6.8.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a36224c3276f8c4ebc8c20f158eca7ca4359c8db89991c4925132aaaf6702661" +checksum = "b1e7d90385b59f0a6bf3d3b757f3ca4ece2048265d70db20a2016043d4509a40" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -2256,9 +2293,9 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "6.8.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b94b81e5b2c284684141a2fb9e2a31be90638caf040bf9afbc5a0416afe1ac" +checksum = "3c3d8c6fd84090ae348e63a84336b112b5c3918b3bf0493a581f7bd8ee623c29" dependencies = [ "proc-macro2", "quote", @@ -2270,9 +2307,9 @@ dependencies = [ [[package]] name = "rust-embed-utils" -version = "7.8.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d38ff6bf570dc3bb7100fce9f7b60c33fa71d80e88da3f2580df4ff2bdded74" +checksum = "873feff8cb7bf86fdf0a71bb21c95159f4e4a37dd7a4bd1855a940909b583ada" dependencies = [ "sha2", "walkdir", @@ -3249,9 +3286,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "utoipa" -version = "3.5.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82b1bc5417102a73e8464c686eef947bdfb99fcdfc0a4f228e81afa9526470a" +checksum = "0ff05e3bac2c9428f57ade702667753ca3f5cf085e2011fe697de5bfd49aa72d" dependencies = [ "indexmap 2.0.2", "serde", @@ -3261,9 +3298,9 @@ dependencies = [ [[package]] name = "utoipa-gen" -version = "3.5.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d96dcd6fc96f3df9b3280ef480770af1b7c5d14bc55192baa9b067976d920c" +checksum = "5f0b6f4667edd64be0e820d6631a60433a269710b6ee89ac39525b872b76d61d" dependencies = [ "proc-macro-error", "proc-macro2", @@ -3275,9 +3312,9 @@ dependencies = [ [[package]] name = "utoipa-swagger-ui" -version = "3.1.5" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84614caa239fb25b2bb373a52859ffd94605ceb256eeb1d63436325cf81e3653" +checksum = "f839caa8e09dddc3ff1c3112a91ef7da0601075ba5025d9f33ae99c4cb9b6e51" dependencies = [ "axum", "mime_guess", diff --git a/Cargo.toml b/Cargo.toml index aa5dc45..d4b54ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.6.9" +version = "0.6.10" edition = "2021" license = "Apache-2.0" repository = "https://github.com/amphitheatre-app/amphitheatre" @@ -21,7 +21,7 @@ members = [ # https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacedependencies-table [workspace.dependencies] anyhow = "1.0" -amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.5.5" } +amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.5.6" } amp-resolver = { path = "resolver" } amp-resources = { path = "resources" } async-nats = "0.33.0" diff --git a/apiserver/Cargo.toml b/apiserver/Cargo.toml index 56d4ff5..64bc15c 100644 --- a/apiserver/Cargo.toml +++ b/apiserver/Cargo.toml @@ -17,7 +17,7 @@ amp-common = { workspace = true, optional = false } amp-resources = { workspace = true, optional = false } async-nats = { workspace = true, optional = false } anyhow = { workspace = true, optional = false } -axum = { version = "0.6", features = ["headers"] } +axum = { version = "0.7.1" } clap = { workspace = true, optional = false } dotenv = { workspace = true, optional = false } futures = { workspace = true, optional = false } @@ -34,8 +34,8 @@ tower = { version = "0.4.13", features = ["full"] } tower-http = { version = "0.5.0", features = ["full"] } tracing = { workspace = true, optional = false } tracing-subscriber = { workspace = true, optional = false } -utoipa = { version = "3", features = ["axum_extras", "uuid", "chrono"] } -utoipa-swagger-ui = { version = "3", features = ["axum"] } +utoipa = { version = "4.1.0", features = ["axum_extras", "uuid", "chrono"] } +utoipa-swagger-ui = { version = "5.0.0", features = ["axum"] } uuid = { version = "1.6.1", features = ["serde", "v4", "fast-rng", "macro-diagnostics"] } url = { workspace = true, optional = false } chrono = "0.4.31" diff --git a/apiserver/src/app.rs b/apiserver/src/app.rs index 55cd608..e7e2fd2 100644 --- a/apiserver/src/app.rs +++ b/apiserver/src/app.rs @@ -15,25 +15,21 @@ use std::net::SocketAddr; use std::sync::Arc; -use axum::Server; - use crate::context::Context; use crate::{routes, swagger}; pub async fn run(ctx: Arc) { let port = ctx.config.port; + // build our application with a route let app = routes::build().merge(swagger::build()).with_state(ctx); - // run it + // run our app with hyper, and serve it over HTTP let addr = SocketAddr::from(([0, 0, 0, 0], port)); - let service = app.into_make_service_with_connect_info::(); - let server = Server::bind(&addr).serve(service).with_graceful_shutdown(async move { - tokio::signal::ctrl_c().await.ok(); - }); + let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); // Run this server for ... forever! - if let Err(err) = server.await { + if let Err(err) = axum::serve(listener, app).await { tracing::error!("Server error: {}", err); std::process::exit(1) }