-
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
feat(tonic): Use BoxBody
from http-body
crate
#622
Conversation
Not quite sure why the interop tests are failing. They work for me locally. I'm on macOS. |
@davidpdrsn are you sure you are running the right tests locally? There is a custom body impl to merge the trailers in the interop tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing all that red in the diff makes me extremely happy!!!
I can reproduce the interop failure locally as well now. I'll look into it. |
As of `http-body` 0.4.1 its has had a `BoxBody` type similar to `tonic::body::BoxBody`. It also has `Empty` and `Body::map_{data,err}`. That means all the custom body things we had in tonic can basically be replaced with that. Note that this is a breaking change so we should merge this next time we decide to ship a breaking release. The breaking changes are: - `tonic::body::Body` has been removed. I think its fine for users to depend directly on `http-body` if they need this trait. - `tonic::body::BoxBody` is now just a type alias for `http_body::combinators::BoxBody<Bytes, Status>`. So the methods it previously had are gone. The replacements are - `tonic::body::Body::new` -> `http_body::Body::boxed` - `tonic::body::Body::map_from` -> `http_body::Body::map_data` and `http_body::Body::map_err` depending on which part you want to map. - `tonic::body::Body::empty` -> `http_body::Empty` Additionally a `Sync` bound has been added to a few methods. I actually don't think this is a breaking change because the old `tonic::body::Body` trait had `Sync` as a supertrait meaning the `Sync` requirement was already there. Fixes #557
I noticed this while working on hyperium/tonic#622 as it broke some interop tests.
The bug caught by the interop tests was in |
074f083
to
1f14b9e
Compare
BoxBody
from http-body
crateBoxBody
from http-body
crate
I noticed this while working on hyperium/tonic#622 as it broke some interop tests.
@@ -1,337 +0,0 @@ | |||
/// The message sent by the client when calling ServerReflectionInfo method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why were these deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought thats what you mean by #622 (comment).
Not sure what those files were for anyway. Removing them didn't break anything 🤔
@@ -71,8 +71,8 @@ impl<T> Grpc<T> { | |||
) -> Result<Response<M2>, Status> | |||
where | |||
T: GrpcService<BoxBody>, | |||
T::ResponseBody: Body + HttpBody + Send + 'static, | |||
<T::ResponseBody as HttpBody>::Error: Into<crate::Error>, | |||
T::ResponseBody: Body + Send + Sync + 'static, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sync is new here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and no. The old tonic::body::Body
had Sync
as a super trait so previously Sync
was implicitly required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense!
…ium#42) I noticed this while working on hyperium/tonic#622 as it broke some interop tests.
As of
http-body
0.4.1 its has had aBoxBody
type similar totonic::body::BoxBody
. It also hasEmpty
andBody::map_{data,err}
.That means all the custom body things we had in tonic can basically be
replaced with that.
Note that this is a breaking change so we should merge this next time we
decide to ship a breaking release.
The breaking changes are:
tonic::body::Body
has been removed. I think its fine for users todepend directly on
http-body
if they need this trait.tonic::body::BoxBody
is now just a type alias forhttp_body::combinators::BoxBody<Bytes, Status>
. So the methods itpreviously had are gone. The replacements are
tonic::body::Body::new
->http_body::Body::boxed
tonic::body::Body::map_from
->http_body::Body::map_data
andhttp_body::Body::map_err
depending on which part you want to map.tonic::body::Body::empty
->http_body::Empty
Additionally a
Sync
bound has been added to a few methods. I actuallydon't think this is a breaking change because the old
tonic::body::Body
trait hadSync
as a supertrait meaning theSync
requirement was already there.
Fixes #557