pub struct Grpc<T> { /* private fields */ }
Expand description
A gRPC client dispatcher.
This will wrap some inner GrpcService
and will encode/decode
messages via the provided codec.
Each request method takes a Request
, a PathAndQuery
, and a
Codec
. The request contains the message to send via the
Codec::encoder
. The path determines the fully qualified path
that will be append to the outgoing uri. The path must follow
the conventions explained in the gRPC protocol definition under Path →
. An
example of this path could look like /greeter.Greeter/SayHello
.
Implementations§
Source§impl<T> Grpc<T>
impl<T> Grpc<T>
Sourcepub fn new(inner: T) -> Self
pub fn new(inner: T) -> Self
Creates a new gRPC client with the provided GrpcService
.
Sourcepub async fn ready(&mut self) -> Result<(), T::Error>where
T: GrpcService<BoxBody>,
pub async fn ready(&mut self) -> Result<(), T::Error>where
T: GrpcService<BoxBody>,
Check if the inner GrpcService
is able to accept a new request.
This will call GrpcService::poll_ready
until it returns ready or
an error. If this returns ready the inner GrpcService
is ready to
accept one more request.
Sourcepub async fn unary<M1, M2, C>(
&mut self,
request: Request<M1>,
path: PathAndQuery,
codec: C,
) -> Result<Response<M2>, Status>
pub async fn unary<M1, M2, C>( &mut self, request: Request<M1>, path: PathAndQuery, codec: C, ) -> Result<Response<M2>, Status>
Send a single unary gRPC request.
Sourcepub async fn client_streaming<S, M1, M2, C>(
&mut self,
request: Request<S>,
path: PathAndQuery,
codec: C,
) -> Result<Response<M2>, Status>
pub async fn client_streaming<S, M1, M2, C>( &mut self, request: Request<S>, path: PathAndQuery, codec: C, ) -> Result<Response<M2>, Status>
Send a client side streaming gRPC request.
Sourcepub async fn server_streaming<M1, M2, C>(
&mut self,
request: Request<M1>,
path: PathAndQuery,
codec: C,
) -> Result<Response<Streaming<M2>>, Status>
pub async fn server_streaming<M1, M2, C>( &mut self, request: Request<M1>, path: PathAndQuery, codec: C, ) -> Result<Response<Streaming<M2>>, Status>
Send a server side streaming gRPC request.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Grpc<T>where
T: Freeze,
impl<T> RefUnwindSafe for Grpc<T>where
T: RefUnwindSafe,
impl<T> Send for Grpc<T>where
T: Send,
impl<T> Sync for Grpc<T>where
T: Sync,
impl<T> Unpin for Grpc<T>where
T: Unpin,
impl<T> UnwindSafe for Grpc<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request