pub struct CoalescingClient<C> {
pub inner: C,
/* private fields */
}Expand description
A coalescing + optional-cache wrapper around a tonic-generated client.
Call CoalescingClient::call from within generated method wrappers,
passing the encoded request bytes, service path, method name, and the
upstream closure. Coalescing and caching are handled transparently.
Fields§
§inner: CThe wrapped tonic-generated client.
Implementations§
Source§impl<C> CoalescingClient<C>
impl<C> CoalescingClient<C>
Sourcepub fn builder(inner: C) -> CoalescingClientBuilder<C>
pub fn builder(inner: C) -> CoalescingClientBuilder<C>
Start a builder for granular per-method configuration.
Sourcepub async fn call<R, F, Fut>(
&self,
service: &str,
method: &str,
req_bytes: Vec<u8>,
upstream: F,
) -> Result<Response<R>, Status>
pub async fn call<R, F, Fut>( &self, service: &str, method: &str, req_bytes: Vec<u8>, upstream: F, ) -> Result<Response<R>, Status>
Execute a coalesced (and optionally cached) unary call.
service: gRPC service path, e.g."auth.v1.AuthService".method: method name, e.g."Check".req_bytes:prost::Message::encode_to_vec(&request)— the caller encodes once and passes the bytes for key derivation.upstream: async closure that performs the actual tonic call and returnsResult<Response<R>, Status>.
R must be Clone + Send + Sync + 'static so it can be shared
across waiters and stored in the cache.
Streaming calls must not use this method. Pass through to self.inner directly.
Auto Trait Implementations§
impl<C> !RefUnwindSafe for CoalescingClient<C>
impl<C> !UnwindSafe for CoalescingClient<C>
impl<C> Freeze for CoalescingClient<C>where
C: Freeze,
impl<C> Send for CoalescingClient<C>where
C: Send,
impl<C> Sync for CoalescingClient<C>where
C: Sync,
impl<C> Unpin for CoalescingClient<C>where
C: Unpin,
impl<C> UnsafeUnpin for CoalescingClient<C>where
C: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Wrap the input message
T in a tonic::Request