Struct Grpc
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§
§impl<T> Grpc<T>
impl<T> Grpc<T>
pub fn new(inner: T, origin: Uri) -> Grpc<T>
pub fn new(inner: T, origin: Uri) -> Grpc<T>
Creates a new gRPC client with the provided GrpcService and Uri.
The provided Uri will use only the scheme and authority parts as the path_and_query portion will be set for each method.
pub fn into_inner(self) -> T
pub fn with_send_compressed(self, encoding: CompressionEncoding) -> Grpc<T>
pub fn with_send_compressed(self, encoding: CompressionEncoding) -> Grpc<T>
Compress requests with the provided encoding.
Requires the server to accept the specified encoding, otherwise it might return an error.
pub fn set_send_compressed(
&mut self,
encoding: CompressionEncoding,
) -> &mut Grpc<T>
pub fn set_send_compressed( &mut self, encoding: CompressionEncoding, ) -> &mut Grpc<T>
Compress requests with the provided encoding.
Requires the server to accept the specified encoding, otherwise it might return an error.
pub fn with_accept_compressed(self, encoding: CompressionEncoding) -> Grpc<T>
pub fn with_accept_compressed(self, encoding: CompressionEncoding) -> Grpc<T>
Enable accepting compressed responses.
Requires the server to also support sending compressed responses.
pub fn set_accept_compressed(
&mut self,
encoding: CompressionEncoding,
) -> &mut Grpc<T>
pub fn set_accept_compressed( &mut self, encoding: CompressionEncoding, ) -> &mut Grpc<T>
Enable accepting compressed responses.
Requires the server to also support sending compressed responses.
pub fn with_max_decoding_message_size(self, limit: usize) -> Grpc<T>
pub fn with_max_decoding_message_size(self, limit: usize) -> Grpc<T>
Limits the maximum size of a decoded message.
pub fn set_max_decoding_message_size(&mut self, limit: usize) -> &mut Grpc<T>
pub fn set_max_decoding_message_size(&mut self, limit: usize) -> &mut Grpc<T>
Limits the maximum size of a decoded message.
pub fn with_max_encoding_message_size(self, limit: usize) -> Grpc<T>
pub fn with_max_encoding_message_size(self, limit: usize) -> Grpc<T>
Limits the maximum size of an encoded message.
pub fn set_max_encoding_message_size(&mut self, limit: usize) -> &mut Grpc<T>
pub fn set_max_encoding_message_size(&mut self, limit: usize) -> &mut Grpc<T>
Limits the maximum size of an encoded message.
pub async fn unary<M1, M2, C>(
&self,
request: Request<M1>,
path: PathAndQuery,
codec: C,
) -> Result<Response<M2>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
pub async fn unary<M1, M2, C>(
&self,
request: Request<M1>,
path: PathAndQuery,
codec: C,
) -> Result<Response<M2>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a single unary gRPC request.
pub async fn client_streaming<S, M1, M2, C>(
&self,
request: Request<S>,
path: PathAndQuery,
codec: C,
) -> Result<Response<M2>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
pub async fn client_streaming<S, M1, M2, C>(
&self,
request: Request<S>,
path: PathAndQuery,
codec: C,
) -> Result<Response<M2>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a client side streaming gRPC request.
pub async fn server_streaming<M1, M2, C>(
&self,
request: Request<M1>,
path: PathAndQuery,
codec: C,
) -> Result<Response<Streaming<M2>>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
pub async fn server_streaming<M1, M2, C>(
&self,
request: Request<M1>,
path: PathAndQuery,
codec: C,
) -> Result<Response<Streaming<M2>>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a server side streaming gRPC request.
pub async fn streaming<S, M1, M2, C>(
&self,
request: Request<S>,
path: PathAndQuery,
codec: C,
) -> Result<Response<Streaming<M2>>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
pub async fn streaming<S, M1, M2, C>(
&self,
request: Request<S>,
path: PathAndQuery,
codec: C,
) -> Result<Response<Streaming<M2>>, Status>where
T: GrpcService<Body>,
<T as GrpcService<Body>>::ResponseBody: Body + Send + Sync + 'static,
<<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2> + Send + Sync + 'static,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a bi-directional streaming gRPC request.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Grpc<T>
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more