Skip to main content

ClientFactory

Struct ClientFactory 

Source
pub struct ClientFactory { /* private fields */ }
Expand description

Фабрика клиентов: единственный способ создать клиент к соседу.

Канал к адресу создаётся один раз и переиспользуется. Соединение устанавливается лениво, при первом вызове.

Implementations§

Source§

impl ClientFactory

Source

pub fn new(settings: Settings, load: Arc<dyn CallLoad>) -> Self

Фабрика с настройками settings и учётом исходящей нагрузки load.

Source

pub fn settings(&self) -> &Settings

Настройки клиентов.

Source

pub fn channel(&self, address: &Address) -> Result<Channel, ClientError>

Канал к адресу address; новый канал кэшируется.

§Ошибки

TLS (https, grpcs) пока не поддержан: соединение шифруется транспортом, настроек которого у платформы нет.

Source

pub fn detached(&self) -> Self

Копия фабрики с собственным кэшем каналов.

Нужна разовым проверкам: неудачная попытка в проверочном канале не оставляет ошибку в канале службы и не влияет на её первый вызов.

Source

pub fn health(&self, address: &Address) -> Result<HealthClient, ClientError>

Клиент проверки состояния к адресу address.

Source

pub fn info(&self, address: &Address) -> Result<InfoClient, ClientError>

Клиент сведений к адресу address.

Source

pub fn metrics(&self, address: &Address) -> Result<MetricsClient, ClientError>

Клиент метрик к адресу address.

Source

pub fn control(&self, address: &Address) -> Result<ControlClient, ClientError>

Клиент управления к адресу address.

Source§

impl ClientFactory

Source

pub fn generated<C>( &self, address: &Address, build: impl Fn(Channel) -> C, ) -> Result<GeneratedClient<C>, ClientError>

Создаёт клиента сгенерированного контракта к адресу address.

Замыкание build получает канал фабрики и возвращает готовый сгенерированный клиент; в нём же задаются пределы сообщений и принимаемые кодировки сжатия.

Trait Implementations§

Source§

impl Clone for ClientFactory

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ClientFactory

§

impl !UnwindSafe for ClientFactory

§

impl Forget for ClientFactory

§

impl Freeze for ClientFactory
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, *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for ClientFactory

§

impl Send for ClientFactory
where Arc<Settings>: Send, Arc<dyn CallLoad>: Send, Arc<ClientLog>: Send, Arc<Inner>: Send,

§

impl Sync for ClientFactory
where Arc<Settings>: Sync, Arc<dyn CallLoad>: Sync, Arc<ClientLog>: Sync, Arc<Inner>: Sync,

§

impl Unpin for ClientFactory
where Arc<Settings>: Unpin, Arc<dyn CallLoad>: Unpin, Arc<ClientLog>: Unpin, Arc<Inner>: Unpin,

§

impl UnsafeUnpin for ClientFactory
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, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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