Client trait to allow for generic wrappers
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
This is related to #671 though I didn't want to bump the old issue.
It would be really helpful if there were a common trait implemented by all tonic clients that contained functions like `with_interceptor`, `with_origin`, etc.
I think previous issues on this topic were for the purposes of mocking which is appropriately handled by the example in the repo, but this doesn't solve the issue of wanting to write generic client wrappers.
For example, I'd like to create a wrapper that adds a mandatory interceptor for all outgoing requests, regardless of which service it's to.
Something like
```
struct RpcWrapper {
client: T
}
impl RpcWrapper {
fn new(channel: Channel) -> Self {
RpcWrapper {
client: T::with_interceptor(channel, MyInterceptor)
}
}
}
```
and then with an appropriate `Deref` impl, this wrapper should otherwise act exactly like the concrete client type.
Contributor guide
Assessment
This issue has not been assessed yet.