-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Upgrade to Hyper 1.0 & Axum 0.7 #1670
Commits on Jun 12, 2024
-
Upgrades only in Cargo.toml Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 20369f5 - Browse repository at this point
Copy the full SHA 20369f5View commit details -
Convert from hyper::Body to http_body::BoxedBody
When appropriate, we replace `hyper::Body` with `http_body::BoxedBody`, a good general purpose replacement for `hyper::Body`. Hyper does provide `hyper::body::Incoming`, but we cannot construct that, so anywhere we might need a body that we can construct (even most Service trait impls) we must use something like `http_body::BoxedBody`. When a service accepts `BoxedBody` and not `Incoming`, this indicates that the service is designed to run in places where it is not adjacent to hyper, for example, after routing (which is managed by Axum) Additionally, http >= 1 requires that extension types are `Clone`, so this bound has been added where appropriate. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for aaede1e - Browse repository at this point
Copy the full SHA aaede1eView commit details -
Convert tonic::codec::decode to use http >= 1 body types
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods. Co-authored-by: Ivan Krivosheev <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ac2698d - Browse repository at this point
Copy the full SHA ac2698dView commit details -
Convert tonic::transport::channel to use http >= 1 body types
tonic::transport::channel previously used `hyper::Body` as the response body type. This type no longer exists in hyper >= 1, and so has been converted to a `BoxBody` provided by `http_body_util` designed for interoperability between http crates. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3ef308c - Browse repository at this point
Copy the full SHA 3ef308cView commit details -
[tests] Convert tonic::codec::prost::tests to use http >= 1 body types
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods. This also handles the return types which should now be wrapped in `Frame` when appropriate. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8a24c79 - Browse repository at this point
Copy the full SHA 8a24c79View commit details -
Convert tonic::codec::encode to use http >= 1 body types
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e0f0f6c - Browse repository at this point
Copy the full SHA e0f0f6cView commit details -
[tests] Convert tonic::service::interceptor::tests to use http >= 1 b…
…ody types The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods. This also handles the return types which should now be wrapped in `Frame` when appropriate. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 51cf7dc - Browse repository at this point
Copy the full SHA 51cf7dcView commit details -
Convert tonic::transport to use http >= 1 body types
Here, we must update some body types which are no longer valid. (A) BoxBody no longer has an `empty` method, instead we provide a helper in `tonic::body` for creating an empty boxed body via `http_body_util`. As well, `hyper::Body` is no longer a type, and instead, `hyper::Incoming` is used when directly recieving a Request from hyper, and `BoxBody` is used when the request may have passed through an axum router. In tonic, we prefer `BoxBody` as it allows for services to be used downstream from other components which enforce a specific body type (e.g. Axum), at the cost of making Body streaming opaque. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 4bf003b - Browse repository at this point
Copy the full SHA 4bf003bView commit details -
Convert tonic::transport::server::recover_error to use http >= 1 body…
… types The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Ludea <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 70abf84 - Browse repository at this point
Copy the full SHA 70abf84View commit details -
Convert h2c examples to use http >= 1 body types
In h2c, when a service is receiving from hyper, it has to accept a `hyper::body::Incoming` in hyper >= 1. Additionally, response bodies must be built from `http_body_util` combinators and become BoxBody objects.
Configuration menu - View commit details
-
Copy full SHA for c5d0d13 - Browse repository at this point
Copy the full SHA c5d0d13View commit details -
[tests] Convert MergeTrailers body wrapper in interop server
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods.
Configuration menu - View commit details
-
Copy full SHA for c3ce3b3 - Browse repository at this point
Copy the full SHA c3ce3b3View commit details -
[tests] Convert compression tests to use hyper 1 body types
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods.
Configuration menu - View commit details
-
Copy full SHA for f2f7870 - Browse repository at this point
Copy the full SHA f2f7870View commit details -
[tests] Convert complex_tower_middleware Body for hyper 1
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods.
Configuration menu - View commit details
-
Copy full SHA for 829eb3b - Browse repository at this point
Copy the full SHA 829eb3bView commit details -
[tests] Convert integration_tests::origin to use http >= 1 body types
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods.
Configuration menu - View commit details
-
Copy full SHA for 55f9edb - Browse repository at this point
Copy the full SHA 55f9edbView commit details -
Convert tonic-web to use http >= 1 body types
The Body trait has changed (removed `poll_data` and `poll_trailers`, they are now combined in `poll_frame`) and so the codec must be re-written to merge those two methods.
Configuration menu - View commit details
-
Copy full SHA for 26e640e - Browse repository at this point
Copy the full SHA 26e640eView commit details -
Adapt for hyper-specific IO traits
hyper >= 1 provides its own I/O traits (Read & Write) instead of relying on the equivalent traits from `tokio`. Then, `hyper-util` provides adaptor structs to wrap `tokio` I/O objects and implement the hyper equivalents. Therefore, we update the appropriate bounds to use the hyper traits, and update the I/O objects so that they are wrapped in the tokio to hyper adaptor. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0e903cb - Browse repository at this point
Copy the full SHA 0e903cbView commit details -
Axum must be >= 0.7 to support hyper >= 1 Doing this also involves changing the Body type used. Since hyper >= 1 does not provide a generic body type, Axum and tonic both use `BoxBody` to provide a pointer to a Body. This changes the trait bounds required for methods which accept additional Serivces to be run alongside the primary GRPC service, since those will be routed with Axum, and therefore must accept a BoxBody. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e1e1ffe - Browse repository at this point
Copy the full SHA e1e1ffeView commit details -
Convert service connector for hyper-1.0
Hyper >= 1 no longer includes automatic http2/http1 combined connections, and so we must swtich to the `http2::Builder` type (this is okay, we set http2_only(true) anyhow). As well, hyper >= 1 is generic over executors and does not directly depend on tokio. Since http2 connections can be multiplexed, they require some additional background task to handle sending and receiving requests. Additionally, these background tasks do not natively implement `tower::Service` since hyper >= 1 does not depend on `tower`. Therefore, we re-implement the `SendRequest` task as a tower::Service, so that it can be used within `Connection`, which expects to operate on a tower::Service to serve connections. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 7a5d95c - Browse repository at this point
Copy the full SHA 7a5d95cView commit details -
Convert hyper::Client to hyper_util::legacy::Client
`hyper::Client` has been moved to `hyper_util::legacy::Client` in version 1. Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ef542bc - Browse repository at this point
Copy the full SHA ef542bcView commit details -
Identify and propogate connect errors
hyper::Error no longer provides information about Connect errors, especially since hyper_util now contains the connection implementation, it does not provide a separate error type. Instead, we create an internal Error type which is used in our own connectors, and then checked when figuring out what the gRPC status should be.
Configuration menu - View commit details
-
Copy full SHA for 9c6b63a - Browse repository at this point
Copy the full SHA 9c6b63aView commit details -
Remove hyper::server::conn::AddrStream
hyper >= 1 has deprecated all of `hyper::server`, including `AddrStream` Co-authored-by: Ivan Krivosheev <[email protected]> Co-authored-by: Allan Zhang <[email protected]> Replace hyper::server::Accept hyper::server is deprectaed. Instead, we implement our own TCP-incoming based on the now removed hyper::server::Accept. In order to set `TCP_KEEPALIVE` we require the socket2 crate, since this option is not exposed in the standard library’s API. The implementaiton is inspired by that of hyper v0.14
Configuration menu - View commit details
-
Copy full SHA for 39e9d57 - Browse repository at this point
Copy the full SHA 39e9d57View commit details -
[examples] In h2c, replace hyper::Server with an accept loop
hyper::Server is deprecated, with no current common replacement. Instead of implementing (or using tonic’s new) full server in here, we write a simple accept loop, which is sufficient to demonstrate the functionality of h2c.
Configuration menu - View commit details
-
Copy full SHA for ca9a859 - Browse repository at this point
Copy the full SHA ca9a859View commit details -
hyper-rustls requires version 0.27.0 to support hyper >= 1, bringing a few other tls bumps along. Importantly, we add the “ring” and “tls12” features to use ring as the crypto backend, consistent with previous versions of tonic. A future version of tonic might support selecting backends via features. Co-authored-by: Ivan Krivosheev <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 32c9183 - Browse repository at this point
Copy the full SHA 32c9183View commit details -
Combine trailers when streaming decode body
We aren't sure if multiple trailers should even be legal, but if we get multiple trailers in an HTTP body stream, we'll combine them all, to preserve their data. Alternatively we'd have to pick the first or last trailers, and that might lose information.
Configuration menu - View commit details
-
Copy full SHA for ed74e45 - Browse repository at this point
Copy the full SHA ed74e45View commit details -
Tweak imports in transport example
Example used `empty_body()`, which is now fully qualified as `tonic::body::empty_body()` to make clear that this is a tonic helper method for creating an empty BoxBody.
Configuration menu - View commit details
-
Copy full SHA for 855ec61 - Browse repository at this point
Copy the full SHA 855ec61View commit details -
Configuration menu - View commit details
-
Copy full SHA for bd9de54 - Browse repository at this point
Copy the full SHA bd9de54View commit details -
Configuration menu - View commit details
-
Copy full SHA for deab62b - Browse repository at this point
Copy the full SHA deab62bView commit details -
tonic-web: Merge subsequent trailer frames
Ideally, a body should only return a single trailer frame. If multiple trailers are returned, merge them together.
Configuration menu - View commit details
-
Copy full SHA for 39f9f11 - Browse repository at this point
Copy the full SHA 39f9f11View commit details -
Comment in tonic::status::find_status_in_source_chain
Comment mentions why we choose “Unavailable” for connection errors
Configuration menu - View commit details
-
Copy full SHA for 791b138 - Browse repository at this point
Copy the full SHA 791b138View commit details -
Make TowerToHyperService crate-private
This also requires vendoring it in the rustls example, which doesn’t use a server type. Making the type crate-private means we can delete some unused methods.
Configuration menu - View commit details
-
Copy full SHA for 8345dfe - Browse repository at this point
Copy the full SHA 8345dfeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 68a5bbd - Browse repository at this point
Copy the full SHA 68a5bbdView commit details