Skip to content

Commit 58345a6

Browse files
authored
chore: Update to tower 0.5 (#1892)
1 parent 80dd77a commit 58345a6

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

examples/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ tonic-types = { path = "../tonic-types", optional = true }
300300
async-stream = { version = "0.3", optional = true }
301301
tokio-stream = { version = "0.1", optional = true }
302302
tokio-util = { version = "0.7.8", optional = true }
303-
tower = { version = "0.4", optional = true }
303+
tower = { version = "0.5", optional = true }
304304
rand = { version = "0.8", optional = true }
305305
serde = { version = "1.0", features = ["derive"], optional = true }
306306
serde_json = { version = "1.0", optional = true }
@@ -318,7 +318,7 @@ h2 = { version = "0.4", optional = true }
318318
tokio-rustls = { version = "0.26", optional = true, features = ["ring", "tls12"], default-features = false }
319319
hyper-rustls = { version = "0.27.0", features = ["http2", "ring", "tls12"], optional = true, default-features = false }
320320
rustls-pemfile = { version = "2.0.0", optional = true }
321-
tower-http = { version = "0.5", optional = true }
321+
tower-http = { version = "0.6", optional = true }
322322
pin-project = { version = "1.0.11", optional = true }
323323

324324
[build-dependencies]

interop/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ prost = "0.13"
2626
tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]}
2727
tokio-stream = "0.1"
2828
tonic = {path = "../tonic", features = ["tls"]}
29-
tower = {version = "0.4"}
29+
tower = "0.5"
3030
tracing-subscriber = {version = "0.3"}
3131

3232
[build-dependencies]

tests/compression/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ prost = "0.13"
1919
tokio = {version = "1.0", features = ["macros", "rt-multi-thread", "net"]}
2020
tokio-stream = "0.1"
2121
tonic = {path = "../../tonic", features = ["gzip", "zstd"]}
22-
tower = {version = "0.4", features = []}
23-
tower-http = {version = "0.5", features = ["map-response-body", "map-request-body"]}
22+
tower = "0.5"
23+
tower-http = {version = "0.6", features = ["map-response-body", "map-request-body"]}
2424

2525
[build-dependencies]
2626
tonic-build = {path = "../../tonic-build" }

tests/integration_tests/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ http = "1"
2121
http-body = "1"
2222
hyper-util = "0.1"
2323
tokio-stream = {version = "0.1.5", features = ["net"]}
24-
tower = {version = "0.4", features = []}
25-
tower-http = { version = "0.5", features = ["set-header", "trace"] }
24+
tower = "0.5"
25+
tower-http = { version = "0.6", features = ["set-header", "trace"] }
2626
tower-service = "0.3"
2727
tracing = "0.1"
2828

tonic-web/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pin-project = "1"
2525
tonic = { version = "0.12", path = "../tonic", default-features = false }
2626
tower-service = "0.3"
2727
tower-layer = "0.3"
28-
tower-http = { version = "0.5", features = ["cors"] }
28+
tower-http = { version = "0.6", features = ["cors"] }
2929
tracing = "0.1"
3030

3131
[dev-dependencies]

tonic/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ hyper = {version = "1", features = ["http1", "http2"], optional = true}
8484
hyper-util = { version = "0.1.4", features = ["tokio"], optional = true }
8585
socket2 = { version = "0.5", optional = true, features = ["all"] }
8686
tokio = {version = "1", default-features = false, optional = true}
87-
tower = {version = "0.4.7", default-features = false, optional = true}
87+
tower = {version = "0.5", default-features = false, optional = true}
8888
axum = {version = "0.7", default-features = false, optional = true}
8989

9090
# rustls
@@ -107,7 +107,7 @@ quickcheck_macros = "1.0"
107107
rand = "0.8"
108108
static_assertions = "1.0"
109109
tokio = {version = "1.0", features = ["rt", "macros"]}
110-
tower = {version = "0.4.7", features = ["full"]}
110+
tower = {version = "0.5", features = ["full"]}
111111

112112
[package.metadata.docs.rs]
113113
all-features = true

tonic/src/transport/channel/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ use tokio::sync::mpsc::{channel, Sender};
2929
use hyper::rt;
3030
use tower::balance::p2c::Balance;
3131
use tower::{
32-
buffer::{self, Buffer},
32+
buffer::{future::ResponseFuture as BufferResponseFuture, Buffer},
3333
discover::{Change, Discover},
34-
util::{BoxService, Either},
34+
util::BoxService,
3535
Service,
3636
};
3737

3838
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
39-
type Svc = Either<Connection, BoxService<Request<BoxBody>, Response<BoxBody>, crate::Error>>;
4039

4140
const DEFAULT_BUFFER_SIZE: usize = 1024;
4241

@@ -65,14 +64,14 @@ const DEFAULT_BUFFER_SIZE: usize = 1024;
6564
/// cloning the `Channel` type is cheap and encouraged.
6665
#[derive(Clone)]
6766
pub struct Channel {
68-
svc: Buffer<Svc, Request<BoxBody>>,
67+
svc: Buffer<Request<BoxBody>, BoxFuture<'static, Result<Response<BoxBody>, crate::Error>>>,
6968
}
7069

7170
/// A future that resolves to an HTTP response.
7271
///
7372
/// This is returned by the `Service::call` on [`Channel`].
7473
pub struct ResponseFuture {
75-
inner: buffer::future::ResponseFuture<<Svc as Service<Request<BoxBody>>>::Future>,
74+
inner: BufferResponseFuture<BoxFuture<'static, Result<Response<BoxBody>, crate::Error>>>,
7675
}
7776

7877
impl Channel {
@@ -156,7 +155,8 @@ impl Channel {
156155
let executor = endpoint.executor.clone();
157156

158157
let svc = Connection::lazy(connector, endpoint);
159-
let (svc, worker) = Buffer::pair(Either::A(svc), buffer_size);
158+
let (svc, worker) = Buffer::pair(svc, buffer_size);
159+
160160
executor.execute(worker);
161161

162162
Channel { svc }
@@ -175,7 +175,7 @@ impl Channel {
175175
let svc = Connection::connect(connector, endpoint)
176176
.await
177177
.map_err(super::Error::from_source)?;
178-
let (svc, worker) = Buffer::pair(Either::A(svc), buffer_size);
178+
let (svc, worker) = Buffer::pair(svc, buffer_size);
179179
executor.execute(worker);
180180

181181
Ok(Channel { svc })
@@ -191,7 +191,7 @@ impl Channel {
191191
let svc = Balance::new(discover);
192192

193193
let svc = BoxService::new(svc);
194-
let (svc, worker) = Buffer::pair(Either::B(svc), buffer_size);
194+
let (svc, worker) = Buffer::pair(svc, buffer_size);
195195
executor.execute(Box::pin(worker));
196196

197197
Channel { svc }

tonic/src/transport/server/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1030,10 +1030,10 @@ where
10301030
.layer(BoxCloneService::layer())
10311031
.map_request(move |mut request: Request<BoxBody>| {
10321032
match &conn_info {
1033-
tower::util::Either::A(inner) => {
1033+
tower::util::Either::Left(inner) => {
10341034
request.extensions_mut().insert(inner.clone());
10351035
}
1036-
tower::util::Either::B(inner) => {
1036+
tower::util::Either::Right(inner) => {
10371037
#[cfg(feature = "tls")]
10381038
{
10391039
request.extensions_mut().insert(inner.clone());

tonic/src/transport/server/service/io.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl<IO> ServerIo<IO> {
3737
IO: Connected,
3838
{
3939
match self {
40-
Self::Io(io) => Either::A(io.connect_info()),
40+
Self::Io(io) => Either::Left(io.connect_info()),
4141
#[cfg(feature = "tls")]
42-
Self::TlsIo(io) => Either::B(io.connect_info()),
42+
Self::TlsIo(io) => Either::Right(io.connect_info()),
4343
}
4444
}
4545
}

0 commit comments

Comments
 (0)