Retry middleware improvements for non-cloneable requests #790
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I wasn't sure how to contribute to this project, so I hope this is a right place to start discussing.
Basically this revision solves real problem that I had with tonic, using retry middleware.
The core of the problem is that tonic (a library that implements gRPC) uses HTTP2, which is by design is streaming protocol. For this reason it is not possible to "clone" tonic request by having just a reference to it.
In order to make request clone-able we need to fully consume it, and then reconstruct original object from consumed bytes.
This revision does exactly that.
CloneableRequest
.CloneableRequest
.There's some more discussion related to this:
I think that it doesn't make sense to solve this issue at tonic side, because it's doesn't make sense for tonic to have cloneable request (image situation where client is streaming multi-gibabyte file, how would you consume it? where would you store it? it's not responsibility of tonic).
On the other hand, if you want to have retry mechanism, you must be aware that a request will be copied in order to be able to retry it.
Any feedback is welcome :)