Struct conjure_runtime::ClientFactory

source ·
pub struct ClientFactory { /* private fields */ }
Expand description

A factory type which can create clients that will live-reload in response to configuration updates.

Implementations§

source§

impl ClientFactory

source

pub fn new(config: Refreshable<ServicesConfig, Error>) -> ClientFactory

Creates a new client factory based off of a refreshable ServicesConfig.

source

pub fn user_agent(&mut self, user_agent: UserAgent) -> &mut Self

Sets the user agent sent by clients.

Required.

source

pub fn get_user_agent(&self) -> Option<&UserAgent>

Returns the configured user agent.

source

pub fn client_qos(&mut self, client_qos: ClientQos) -> &mut Self

Sets clients’ rate limiting behavior.

Defaults to ClientQos::Enabled.

source

pub fn get_client_qos(&self) -> ClientQos

Returns the configured rate limiting behavior

source

pub fn server_qos(&mut self, server_qos: ServerQos) -> &mut Self

Sets clients’ behavior in response to a QoS error from the server.

Defaults to ServerQos::AutomaticRetry.

source

pub fn get_server_qos(&self) -> ServerQos

Returns the configured QoS behavior.

source

pub fn service_error(&mut self, service_error: ServiceError) -> &mut Self

Sets clients’ behavior in response to a service error from the server.

Defaults to ServiceError::WrapInNewError.

source

pub fn get_service_error(&self) -> ServiceError

Returns the configured service error behavior.

source

pub fn idempotency(&mut self, idempotency: Idempotency) -> &mut Self

Sets clients’ behavior to determine if a request is idempotent or not.

Only idempotent requests will be retried.

Defaults to Idempotency::ByMethod.

source

pub fn get_idempotency(&self) -> Idempotency

Returns the configured idempotency behavior.

source

pub fn node_selection_strategy( &mut self, node_selection_strategy: NodeSelectionStrategy ) -> &mut Self

Sets the clients’ strategy for selecting a node for a request.

Defaults to NodeSelectionStrategy::PinUntilError.

source

pub fn get_node_selection_strategy(&self) -> NodeSelectionStrategy

Returns the configured node selection strategy.

source

pub fn metrics(&mut self, metrics: Arc<MetricRegistry>) -> &mut Self

Sets the metric registry used to register client metrics.

Defaults to no registry.

source

pub fn get_metrics(&self) -> Option<&Arc<MetricRegistry>>

Returns the configured metrics registry.

source

pub fn host_metrics( &mut self, host_metrics: Arc<HostMetricsRegistry> ) -> &mut Self

Sets the host metrics registry used to track host performance.

Defaults to no registry.

source

pub fn get_host_metrics(&self) -> Option<&Arc<HostMetricsRegistry>>

Returns the configured host metrics registry.

source

pub fn blocking_handle(&mut self, blocking_handle: Handle) -> &mut Self

Returns the Handle to the tokio Runtime to be used by blocking clients.

This has no effect on async clients.

Defaults to a conjure-runtime internal Runtime.

source

pub fn get_blocking_handle(&self) -> Option<&Handle>

Returns the configured blocking handle.

source

pub fn client<T>(&self, service: &str) -> Result<T, Error>
where T: AsyncService<Client>,

Creates a new client for the specified service.

The client’s configuration will automatically refresh to track changes in the factory’s ServicesConfig.

If no configuration is present for the specified service in the ServicesConfig, the client will immediately return an error for all requests.

The method can return any type implementing the conjure-http AsyncService trait. This notably includes all Conjure-generated client types as well as the conjure-runtime Client itself.

§Panics

Panics if user_agent is not set.

source

pub fn blocking_client<T>(&self, service: &str) -> Result<T, Error>
where T: Service<Client>,

Creates a new blocking client for the specified service.

The client’s configuration will automatically refresh to track changes in the factory’s ServicesConfig.

If no configuration is present for the specified service in the ServicesConfig, the client will immediately return an error for all requests.

The method can return any type implementing the conjure-http Service trait. This notably includes all Conjure-generated client types as well as the conjure-runtime blocking::Client itself.

§Panics

Panics if user_agent is not set.

Trait Implementations§

source§

impl Clone for ClientFactory

source§

fn clone(&self) -> ClientFactory

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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