Unable to integrate tower retry with tonic because http::Request is not Clone
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
Hello community, I'm looking for some guidance.
I'm trying to integrate [retry layer](https://docs.rs/tower/0.3.1/tower/retry/index.html) from [tower](https://crates.io/crates/tower) into my tonic setup in order to enable gRPC retries for some common retryable errors.
My initial setup is almost identical to [this example](https://github.com/hyperium/tonic/blob/master/examples/src/tower/client.rs#L16) with retry policy like [this one](https://docs.rs/tower/0.1.0/tower/retry/trait.Policy.html).
The issue I'm facing is that in order to work correctly, one must implement tower's policy trait including [clone_request](https://github.com/tower-rs/tower/blob/master/tower/src/retry/policy.rs#L66) function. If you don't implement it and return `None` (as documentation suggests in the case when Clone is not implemented for the request) then whole retry logic [will not be executed](https://github.com/tower-rs/tower/blob/master/tower/src/retry/future.rs#L78). Now the problem is that under the hood tonic uses `http::Request`, which is NOT `Clone`.
One one hand I see reasoning behind why `http::Request` should not be clone, but on the other it makes whole retry mechanism unusable.
Is there any work-around for this issue or are there any improvements we can make in tonic or tower in order to eliminate it in the first place (maybe put request behind an Arc?)?
Contributor guide
Assessment
This issue has not been assessed yet.