You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A type that implements tower::Service in the proper way implements GrpcService, but not the other way around.
Channel is a special implementation of GrpcService. It can potentially implement Service as well (making such a wrapper type is easy), but currently it doesn't. Due to this, we can't make use of various tower's wrapper services for a channel.
error[E0277]: the trait bound `tonic::transport::Channel: tower::Service<http::Request<tonic::body::BoxBody>>` is not satisfied
--> src/client.rs:40:41
|
40 | let mut client = GreeterClient::new(conn);
| ^^^^ the trait `tower::Service<http::Request<tonic::body::BoxBody>>` is not implemented for `tonic::transport::Channel`
|
= note: required because of the requirements on the impl of `tower::Service<http::Request<tonic::body::BoxBody>>` for `tower::tower_timeout::Timeout<tonic::transport::Channel>`
= note: required because of the requirements on the impl of `tonic::client::GrpcService<tonic::body::BoxBody>` for `tower::tower_timeout::Timeout<tonic::transport::Channel>`
Proposal
Let's implement tower::Service<http::Request<BoxBody>> for Channel, so that we can make use of tower service wrappers more easily.
Alternatives
To achieve the same goal, users may write a small wrapper for Channel which implements Service.
This adds tower::Service impl for tonic::transport::Channel
and removes GrpcService impl declaration.
Channel still implements GrpcService, thanks to the general
impl declaration of GrpcService for types who implement Service.
Fixeshyperium#481.
* transport: impl Service for Channel instead of GrpcService
This adds tower::Service impl for tonic::transport::Channel
and removes GrpcService impl declaration.
Channel still implements GrpcService, thanks to the general
impl declaration of GrpcService for types who implement Service.
Fixes#481.
* examples: stop using GrpcService to avoid ambiguity
* examples: add timeout example
Feature Request
Motivation
A type that implements
tower::Service
in the proper way implementsGrpcService
, but not the other way around.Channel
is a special implementation ofGrpcService
. It can potentially implementService
as well (making such a wrapper type is easy), but currently it doesn't. Due to this, we can't make use of varioustower
's wrapper services for a channel.Proposal
Let's implement
tower::Service<http::Request<BoxBody>>
forChannel
, so that we can make use oftower
service wrappers more easily.Alternatives
To achieve the same goal, users may write a small wrapper for
Channel
which implementsService
.We can find a similar one in
examples
. But providing a canonicalService
implementation forChannel
would simplify user code?The text was updated successfully, but these errors were encountered: