Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update from tower 0.4 to 0.5 #2004

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 69 additions & 9 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,27 @@ path = "src/codec_buffers/client.rs"

[features]
gcp = ["dep:prost-types", "tonic/tls"]
routeguide = ["dep:async-stream", "tokio-stream", "dep:rand", "dep:serde", "dep:serde_json"]
routeguide = [
"dep:async-stream",
"tokio-stream",
"dep:rand",
"dep:serde",
"dep:serde_json",
]
reflection = ["dep:tonic-reflection"]
autoreload = ["tokio-stream/net", "dep:listenfd"]
health = ["dep:tonic-health"]
grpc-web = ["dep:tonic-web", "dep:bytes", "dep:http", "dep:hyper", "dep:hyper-util", "dep:tracing-subscriber", "dep:tower", "dep:tower-http", "tower-http?/cors"]
grpc-web = [
"dep:tonic-web",
"dep:bytes",
"dep:http",
"dep:hyper",
"dep:hyper-util",
"dep:tracing-subscriber",
"dep:tower",
"dep:tower-http",
"tower-http?/cors",
]
tracing = ["dep:tracing", "dep:tracing-subscriber"]
uds = ["tokio-stream/net", "dep:tower", "dep:hyper", "dep:hyper-util"]
streaming = ["tokio-stream", "dep:h2"]
Expand All @@ -276,15 +292,49 @@ tower = ["dep:tower", "tower?/timeout", "dep:http"]
json-codec = ["dep:serde", "dep:serde_json", "dep:bytes"]
compression = ["tonic/gzip"]
tls = ["tonic/tls"]
tls-rustls = ["dep:http", "dep:hyper", "dep:hyper-util", "dep:hyper-rustls", "dep:tower", "tower-http/util", "tower-http/add-extension", "dep:rustls-pemfile", "dep:tokio-rustls", "dep:pin-project", "dep:http-body-util"]
tls-rustls = [
"dep:http",
"dep:hyper",
"dep:hyper-util",
"dep:hyper-rustls",
"dep:tower",
"tower-http/util",
"tower-http/add-extension",
"dep:rustls-pemfile",
"dep:tokio-rustls",
"dep:pin-project",
"dep:http-body-util",
]
dynamic-load-balance = ["dep:tower"]
timeout = ["tokio/time", "dep:tower", "tower?/timeout"]
tls-client-auth = ["tonic/tls"]
types = ["dep:tonic-types"]
h2c = ["dep:hyper", "dep:tower", "dep:http", "dep:hyper-util"]
cancellation = ["dep:tokio-util"]

full = ["gcp", "routeguide", "reflection", "autoreload", "health", "grpc-web", "tracing", "uds", "streaming", "mock", "tower", "json-codec", "compression", "tls", "tls-rustls", "dynamic-load-balance", "timeout", "tls-client-auth", "types", "cancellation", "h2c"]
full = [
"gcp",
"routeguide",
"reflection",
"autoreload",
"health",
"grpc-web",
"tracing",
"uds",
"streaming",
"mock",
"tower",
"json-codec",
"compression",
"tls",
"tls-rustls",
"dynamic-load-balance",
"timeout",
"tls-client-auth",
"types",
"cancellation",
"h2c",
]
default = ["full"]

[dependencies]
Expand All @@ -300,12 +350,15 @@ tonic-types = { path = "../tonic-types", optional = true }
async-stream = { version = "0.3", optional = true }
tokio-stream = { version = "0.1", optional = true }
tokio-util = { version = "0.7.8", optional = true }
tower = { version = "0.4", optional = true }
tower = { version = "0.5.1", optional = true }
rand = { version = "0.8", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
tracing = { version = "0.1.16", optional = true }
tracing-subscriber = { version = "0.3", features = ["tracing-log", "fmt"], optional = true }
tracing-subscriber = { version = "0.3", features = [
"tracing-log",
"fmt",
], optional = true }
prost-types = { version = "0.13", optional = true }
http = { version = "1", optional = true }
http-body = { version = "1", optional = true }
Expand All @@ -315,10 +368,17 @@ hyper-util = { version = "0.1.4", optional = true }
listenfd = { version = "1.0", optional = true }
bytes = { version = "1", optional = true }
h2 = { version = "0.4", optional = true }
tokio-rustls = { version = "0.26", optional = true, features = ["ring", "tls12"], default-features = false }
hyper-rustls = { version = "0.27.0", features = ["http2", "ring", "tls12"], optional = true, default-features = false }
tokio-rustls = { version = "0.26", optional = true, features = [
"ring",
"tls12",
], default-features = false }
hyper-rustls = { version = "0.27.0", features = [
"http2",
"ring",
"tls12",
], optional = true, default-features = false }
rustls-pemfile = { version = "2.0.0", optional = true }
tower-http = { version = "0.5", optional = true }
tower-http = { version = "0.6.1", optional = true }
pin-project = { version = "1.0.11", optional = true }

[build-dependencies]
Expand Down
13 changes: 8 additions & 5 deletions tests/compression/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ hyper-util = "0.1"
paste = "1.0.12"
pin-project = "1.0"
prost = "0.13"
tokio = {version = "1.0", features = ["macros", "rt-multi-thread", "net"]}
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "net"] }
tokio-stream = "0.1"
tonic = {path = "../../tonic", features = ["gzip", "zstd"]}
tower = {version = "0.4", features = []}
tower-http = {version = "0.5", features = ["map-response-body", "map-request-body"]}
tonic = { path = "../../tonic", features = ["gzip", "zstd"] }
tower = { version = "0.5.1", features = [] }
tower-http = { version = "0.6.1", features = [
"map-response-body",
"map-request-body",
] }

[build-dependencies]
tonic-build = {path = "../../tonic-build" }
tonic-build = { path = "../../tonic-build" }
2 changes: 1 addition & 1 deletion tests/compression/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tonic::{
transport::{Channel, Endpoint, Server, Uri},
Request, Response, Status, Streaming,
};
use tower::{layer::layer_fn, service_fn, Service, ServiceBuilder};
use tower::{layer::layer_fn, Service, ServiceBuilder};
use tower_http::{map_request_body::MapRequestBodyLayer, map_response_body::MapResponseBodyLayer};

mod bidirectional_stream;
Expand Down
2 changes: 1 addition & 1 deletion tests/compression/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub async fn mock_io_channel(client: tokio::io::DuplexStream) -> Channel {

Endpoint::try_from("http://[::]:50051")
.unwrap()
.connect_with_connector(service_fn(move |_: Uri| {
.connect_with_connector(tower::service_fn(move |_: Uri| {
let client = TokioIo::new(client.take().unwrap());
async move { Ok::<_, std::io::Error>(client) }
}))
Expand Down
17 changes: 11 additions & 6 deletions tests/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ version = "0.1.0"
[dependencies]
bytes = "1.0"
prost = "0.13"
tokio = {version = "1.0", features = ["macros", "rt-multi-thread", "net", "sync"]}
tonic = {path = "../../tonic"}
tracing-subscriber = {version = "0.3"}
tokio = { version = "1.0", features = [
"macros",
"rt-multi-thread",
"net",
"sync",
] }
tonic = { path = "../../tonic" }
tracing-subscriber = { version = "0.3" }

[dev-dependencies]
async-stream = "0.3"
http = "1"
http-body = "1"
hyper-util = "0.1"
tokio-stream = {version = "0.1.5", features = ["net"]}
tower = {version = "0.4", features = []}
tokio-stream = { version = "0.1.5", features = ["net"] }
tower = { version = "0.5.1", features = [] }
tower-http = { version = "0.5", features = ["set-header", "trace"] }
tower-service = "0.3"
tracing = "0.1"

[build-dependencies]
tonic-build = {path = "../../tonic-build"}
tonic-build = { path = "../../tonic-build" }
3 changes: 1 addition & 2 deletions tests/integration_tests/tests/connect_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub mod unix {
transport::{server::UdsConnectInfo, Endpoint, Server, Uri},
Request, Response, Status,
};
use tower::service_fn;

use integration_tests::pb::{test_client, test_server, Input, Output};

Expand Down Expand Up @@ -109,7 +108,7 @@ pub mod unix {
let path = unix_socket_path.clone();
let channel = Endpoint::try_from("http://[::]:50051")
.unwrap()
.connect_with_connector(service_fn(move |_: Uri| {
.connect_with_connector(tower::service_fn(move |_: Uri| {
let path = path.clone();
async move { Ok::<_, io::Error>(TokioIo::new(UnixStream::connect(path).await?)) }
}))
Expand Down
2 changes: 1 addition & 1 deletion tonic-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pin-project = "1"
tonic = { version = "0.12", path = "../tonic", default-features = false }
tower-service = "0.3"
tower-layer = "0.3"
tower-http = { version = "0.5", features = ["cors"] }
tower-http = { version = "0.6.1", features = ["cors"] }
tracing = "0.1"

[dev-dependencies]
Expand Down
78 changes: 54 additions & 24 deletions tonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,51 @@ gzip = ["dep:flate2"]
zstd = ["dep:zstd"]
default = ["transport", "codegen", "prost"]
prost = ["dep:prost"]
tls = ["dep:rustls-pemfile", "dep:tokio-rustls", "dep:tokio", "tokio?/rt", "tokio?/macros"]
tls-roots = ["tls-native-roots"] # Deprecated. Please use `tls-native-roots` instead.
tls = [
"dep:rustls-pemfile",
"dep:tokio-rustls",
"dep:tokio",
"tokio?/rt",
"tokio?/macros",
]
tls-roots = [
"tls-native-roots",
] # Deprecated. Please use `tls-native-roots` instead.
tls-native-roots = ["tls", "channel", "dep:rustls-native-certs"]
tls-webpki-roots = ["tls", "channel", "dep:webpki-roots"]
router = ["dep:axum", "dep:tower", "tower?/util"]
server = [
"router",
"dep:async-stream",
"dep:h2",
"dep:hyper", "hyper?/server",
"dep:hyper-util", "hyper-util?/service", "hyper-util?/server-auto",
"dep:hyper",
"hyper?/server",
"dep:hyper-util",
"hyper-util?/service",
"hyper-util?/server-auto",
"dep:socket2",
"dep:tokio", "tokio?/macros", "tokio?/net", "tokio?/time",
"dep:tokio",
"tokio?/macros",
"tokio?/net",
"tokio?/time",
"tokio-stream/net",
"dep:tower", "tower?/util", "tower?/limit",
"dep:tower",
"tower?/util",
"tower?/limit",
]
channel = [
"dep:hyper", "hyper?/client",
"dep:hyper-util", "hyper-util?/client-legacy",
"dep:tower", "tower?/balance", "tower?/buffer", "tower?/discover", "tower?/limit", "tower?/util",
"dep:tokio", "tokio?/time",
"dep:hyper",
"hyper?/client",
"dep:hyper-util",
"hyper-util?/client-legacy",
"dep:tower",
"tower?/balance",
"tower?/buffer",
"tower?/discover",
"tower?/limit",
"tower?/util",
"dep:tokio",
"tokio?/time",
"dep:hyper-timeout",
]
transport = ["server", "channel"]
Expand All @@ -69,45 +93,51 @@ percent-encoding = "2.1"
pin-project = "1.0.11"
tower-layer = "0.3"
tower-service = "0.3"
tokio-stream = {version = "0.1.16", default-features = false}
tokio-stream = { version = "0.1.16", default-features = false }

# prost
prost = {version = "0.13", default-features = false, features = ["std"], optional = true}
prost = { version = "0.13", default-features = false, features = [
"std",
], optional = true }

# codegen
async-trait = {version = "0.1.13", optional = true}
async-trait = { version = "0.1.13", optional = true }

# transport
async-stream = {version = "0.3", optional = true}
h2 = {version = "0.4", optional = true}
hyper = {version = "1", features = ["http1", "http2"], optional = true}
async-stream = { version = "0.3", optional = true }
h2 = { version = "0.4", optional = true }
hyper = { version = "1", features = ["http1", "http2"], optional = true }
hyper-util = { version = "0.1.4", features = ["tokio"], optional = true }
socket2 = { version = "0.5", optional = true, features = ["all"] }
tokio = {version = "1", default-features = false, optional = true}
tower = {version = "0.4.7", default-features = false, optional = true}
axum = {version = "0.7", default-features = false, optional = true}
tokio = { version = "1", default-features = false, optional = true }
tower = { version = "0.5.1", default-features = false, optional = true }
axum = { version = "0.7", default-features = false, optional = true }

# rustls
rustls-pemfile = { version = "2.0", optional = true }
rustls-native-certs = { version = "0.8", optional = true }
tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "tls12", "ring"], optional = true }
tokio-rustls = { version = "0.26", default-features = false, features = [
"logging",
"tls12",
"ring",
], optional = true }
webpki-roots = { version = "0.26", optional = true }

# compression
flate2 = {version = "1.0", optional = true}
flate2 = { version = "1.0", optional = true }
zstd = { version = "0.13.0", optional = true }

# channel
hyper-timeout = {version = "0.5", optional = true}
hyper-timeout = { version = "0.5", optional = true }

[dev-dependencies]
bencher = "0.1.5"
quickcheck = "1.0"
quickcheck_macros = "1.0"
rand = "0.8"
static_assertions = "1.0"
tokio = {version = "1.0", features = ["rt", "macros"]}
tower = {version = "0.4.7", features = ["full"]}
tokio = { version = "1.0", features = ["rt", "macros"] }
tower = { version = "0.5.1", features = ["full"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
Loading