Skip to content

Commit

Permalink
Upgrade tower_http 0.4 => 0.6.2 + features trace + fs
Browse files Browse the repository at this point in the history
Summary:
This upgrade is necessary to work with the newer version of axum used in my gateway service.

## Why can't you just upgrade `tower_http` globally?

**I believe the primary blocker is upgrading rust 3p's `http` to 1:  https://fb.workplace.com/groups/rust.language/permalink/26264445149844085/**

`tower_http 0.62` is incompatible with `tonic_web 0.9.2`, which is used by the `enkaku` tool. Enkaku has these dependencies:

tonic <- tonic_web (implements tower::Service using OLD `http` crate) <- `tower_http::CorsLayer` (implements tower::Service using NEW http crate)

I tried in vain to come up with some kind of an adapter. I was able to convince a bunch of the code in `fbcode/enkaku/http/src/cors.rs` to compile, but I'm unable to do anything with the trait errors in `grpc.rs`.

This is what my error looks like:

```
error[E0277]: the trait bound `tower_http::cors::Cors<GrpcWebService<Routes>>: tonic::codegen::Service<http::Request<tonic::transport::Body>>` is not satisfied
  --> fbcode/enkaku/http/src/grpc.rs:37:18
   |
37 |                 .serve_with_incoming(TcpListenerStream::new(listener)),
   |                  ^^^^^^^^^^^^^^^^^^^ the trait `tonic::codegen::Service<http::Request<tonic::transport::Body>>` is not implemented for `tower_http::cors::Cors<GrpcWebService<Routes>>`
   |
   = help: the trait `tonic::codegen::Service<http::request::Request<ReqBody>>` is implemented for `tower_http::cors::Cors<S>`

error[E0277]: the trait bound `tower_http::cors::Cors<GrpcWebService<Routes>>: tonic::codegen::Service<http::Request<tonic::transport::Body>>` is not satisfied
  --> fbcode/enkaku/http/src/grpc.rs:29:9
   |
29 |         tokio::spawn(
   |         ^^^^^^^^^^^^ the trait `tonic::codegen::Service<http::Request<tonic::transport::Body>>` is not implemented for `tower_http::cors::Cors<GrpcWebService<Routes>>`
   |
   = help: the trait `tonic::codegen::Service<http::request::Request<ReqBody>>` is implemented for `tower_http::cors::Cors<S>`
note: required by a bound in `Router::<L>::serve_with_incoming`
  --> third-party/rust/vendor/tonic-0.9.2/src/transport/server/mod.rs:629:5
```

Reviewed By: dtolnay

Differential Revision: D66669629

fbshipit-source-id: c8c3e97d58599b1b8c2e93d3bd406617ccbe0a62
  • Loading branch information
jefffm authored and facebook-github-bot committed Dec 10, 2024
1 parent 941acaf commit 602be92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shed/fbthrift_ext/socket/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ futures = { version = "0.3.30", features = ["async-await", "compat"] }
tokio = { version = "1.41.0", features = ["full", "test-util", "tracing"] }
tokio-tower = "0.6"
tokio-util = { version = "0.7.12", features = ["full"] }
tower-service = "0.3"
tower-service = "0.3.3"
2 changes: 1 addition & 1 deletion shed/fbthrift_ext/tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ futures = { version = "0.3.30", features = ["async-await", "compat"] }
tokio = { version = "1.41.0", features = ["full", "test-util", "tracing"] }
tokio-tower = "0.6"
tokio-util = { version = "0.7.12", features = ["full"] }
tower-service = "0.3"
tower-service = "0.3.3"

0 comments on commit 602be92

Please sign in to comment.