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

feat(transport): Support timeouts with "grpc-timeout" header #606

Merged
merged 12 commits into from
Apr 29, 2021

Conversation

davidpdrsn
Copy link
Member

This adds support for the grpc-timeout header as is recommended by the gRPC spec.

It replaces use of tower::timeout::Timeout in the server with our own Timeout middleware. That tries to parse the timeout in grpc-timeout header and picks which ever of the server or client timeouts are the shortest.


Most of the implementation is based on #516. cc @ParkMyCar
Fixes #75

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok just did a quick pass, will pull down the code to dig into those test failures shortly here. Overall looks great, left a few comments inline with some questions.

tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/transport/service/timeout.rs Outdated Show resolved Hide resolved
tonic/src/metadata/map.rs Show resolved Hide resolved
@ParkMyCar
Copy link

Ah no worries! Thanks for driving this home 🙂

@LucioFranco
Copy link
Member

@ParkMyCar sorry for the long delay on all of this! Thanks for the patience 😄

@ParkMyCar
Copy link

@LucioFranco no problem! Just glad to see this get closer to landing

@davidpdrsn
Copy link
Member Author

@LucioFranco ready for another round of review!

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for pushing this through, I left a few inline questions but overall I think we can get this shipped. Feel free to prep a release (or tell me you don't have time and I can do it).

tonic/src/metadata/mod.rs Show resolved Hide resolved
match result {
Ok(res) => Poll::Ready(Ok(res)),
Err(err) => {
if let Some(status) = Status::try_from_error(&*err) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to document this actually since its quite unclear. What errors would be returned as a status and which ones would fail? I do think this is the right approach though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seanmonstar what do you think here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any error that Status::try_from_error can downcast will be converted to a response. Do you think we should mention that here or refer to the docs for Status::try_from_error (and write some docs for that method as well maybe)?

@LucioFranco LucioFranco changed the title transport: Support timeouts with "grpc-timeout" header feat(transport): Support timeouts with "grpc-timeout" header Apr 28, 2021
@LucioFranco
Copy link
Member

Oh and CI needs a fix

@davidpdrsn
Copy link
Member Author

I'll go ahead and merge this and work on Request::set_deadline. I think that would be cool to have in a release together with this as they kinda go together.

Will do follow up PRs if the docs could be made clearer 😊

@davidpdrsn davidpdrsn merged commit 9ff4f7b into master Apr 29, 2021
@davidpdrsn davidpdrsn deleted the david/grpc-timeout branch April 29, 2021 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support deadlines with the grpc-timeout header
3 participants