Skip to content

Storing with_interceptor clients is substantially more challenging in 0.5 #730

@Sushisource

Description

@Sushisource

Feature Request

Crates

tonic

Motivation

Previously, I could simply store a FooServiceClient<tonic::transport::Channel> without the need for generics or boxing in a struct, and use that. I do so to encapsulate access to the client, partly for mocking reasons, partly for enforcing certain invariants or making the API simpler.

Now, the type is something like FooServiceClient<tonic::codegen::InterceptedService<Channel, impl Fn<(tonic::Request<()>,)>>> which is a much bigger pain to store.

Proposal

Kind of like #671, but not quite, it would be nice if there was simply a FooServiceClient trait with all the rpc methods on it that the generated structs would implement (using async_trait, maybe opt-in). This would make storage and mocking much simpler.

Alternatives

Beyond having a full client trait, a trait that combines all the bounds in the big where clause on generated clients would also make this much easier. I'm referencing:

    impl<T> FooServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::BoxBody>,
        T::ResponseBody: Body + Send + Sync + 'static,
        T::Error: Into<StdError>,
        <T::ResponseBody as Body>::Error: Into<StdError> + Send,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions