Skip to main content

GeneratedClient

Struct GeneratedClient 

Source
pub struct GeneratedClient<C> { /* private fields */ }
Expand description

Клиент сгенерированного контракта, собранный фабрикой.

Клиент хранит два экземпляра сгенерированного типа: без сжатия запросов и со сжатием. Выбор делается на каждый вызов по размеру сообщения и порогу grpc.compressionThreshold.

Implementations§

Source§

impl<C: Clone> GeneratedClient<C>

Source

pub fn plain(&self) -> C

Клиент без сжатия запросов: для потоков и вызовов, где сжатие не окупается.

Source

pub fn for_message(&self, size: usize) -> C

Клиент для сообщения размером size: сжатый, если режим и порог это разрешают.

Source

pub async fn unary<Req, Resp, F, Fut>( &self, method: &'static str, context: &CallContext, request: Request<Req>, call: F, ) -> Result<Response<Resp>, ClientError>
where Req: Message, F: FnOnce(C, Request<Req>) -> Fut, Fut: Future<Output = Result<Response<Resp>, Status>>,

Одиночный вызов: крайний срок, заголовки, трассировка, учёт нагрузки и запись неудачи.

Размер запроса считается по protobuf-кодировке и решает, сжимать ли вызов.

Source

pub async fn streaming<Req, S, F, Fut>( &self, method: &'static str, context: &CallContext, request: Request<Req>, call: F, ) -> Result<GuardedStream<Streaming<S>>, ClientError>
where F: FnOnce(C, Request<Req>) -> Fut, Fut: Future<Output = Result<Response<Streaming<S>>, Status>>,

Открытие потока: крайний срок, заголовки, трассировка, учёт нагрузки и запись неудачи.

Потоки идут без сжатия запросов: сжатие потока задаётся на весь вызов и решается не по размеру одного сообщения.

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for GeneratedClient<C>

§

impl<C> !UnwindSafe for GeneratedClient<C>

§

impl<C> Forget for GeneratedClient<C>

§

impl<C> Freeze for GeneratedClient<C>
where *const ArcInner<Settings> is !null: Freeze, PhantomData<ArcInner<Settings>>: Freeze, *const ArcInner<dyn CallLoad> is !null: Freeze, PhantomData<ArcInner<dyn CallLoad>>: Freeze, *const ArcInner<ClientLog> is !null: Freeze, PhantomData<ArcInner<ClientLog>>: Freeze, C: Freeze,

§

impl<C> Move for GeneratedClient<C>

§

impl<C> Send for GeneratedClient<C>
where C: Send, Arc<Settings>: Send, Arc<dyn CallLoad>: Send, Arc<ClientLog>: Send,

§

impl<C> Sync for GeneratedClient<C>
where C: Sync, Arc<Settings>: Sync, Arc<dyn CallLoad>: Sync, Arc<ClientLog>: Sync,

§

impl<C> Unpin for GeneratedClient<C>
where C: Unpin, Arc<Settings>: Unpin, Arc<dyn CallLoad>: Unpin, Arc<ClientLog>: Unpin,

§

impl<C> UnsafeUnpin for GeneratedClient<C>
where *const ArcInner<Settings> is !null: UnsafeUnpin, PhantomData<ArcInner<Settings>>: UnsafeUnpin, *const ArcInner<dyn CallLoad> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn CallLoad>>: UnsafeUnpin, *const ArcInner<ClientLog> is !null: UnsafeUnpin, PhantomData<ArcInner<ClientLog>>: UnsafeUnpin, C: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more