pub struct Builder<T = DefaultRawClientBuilder> { /* private fields */ }
Expand description

A builder to construct Clients and blocking::Clients.

Implementations§

source§

impl Builder

source

pub fn new() -> Builder

Creates a new builder with default settings.

source§

impl<T> Builder<T>

source

pub fn from_config(&mut self, config: &ServiceConfig) -> &mut Self

Applies configuration settings from a ServiceConfig to the builder.

source

pub fn service(&mut self, service: &str) -> &mut Self

Sets the name of the service this client will communicate with.

This is used in logging and metrics to allow differentiation between different clients.

Required.

source

pub fn get_service(&self) -> Option<&str>

Returns the builder’s configured service name.

source

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

Sets the user agent sent by this client.

Required.

source

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

Returns the builder’s configured user agent.

source

pub fn uri(&mut self, uri: Url) -> &mut Self

Appends a URI to the URIs list.

Defaults to an empty list.

source

pub fn uris(&mut self, uris: Vec<Url>) -> &mut Self

Sets the URIs list.

Defaults to an empty list.

source

pub fn get_uris(&self) -> &[Url]

Returns the builder’s configured URIs list.

source

pub fn security(&mut self, security: SecurityConfig) -> &mut Self

Sets the security configuration.

Defaults to an empty configuration.

source

pub fn get_security(&self) -> &SecurityConfig

Returns the builder’s configured security configuration.

source

pub fn proxy(&mut self, proxy: ProxyConfig) -> &mut Self

Sets the proxy configuration.

Defaults to ProxyConfig::Direct (i.e. no proxy).

source

pub fn get_proxy(&self) -> &ProxyConfig

Returns the builder’s configured proxy configuration.

source

pub fn connect_timeout(&mut self, connect_timeout: Duration) -> &mut Self

Sets the connect timeout.

Defaults to 10 seconds.

source

pub fn get_connect_timeout(&self) -> Duration

Returns the builder’s configured connect timeout.

source

pub fn read_timeout(&mut self, read_timeout: Duration) -> &mut Self

Sets the read timeout.

This timeout applies to socket-level read attempts.

Defaults to 5 minutes.

source

pub fn get_read_timeout(&self) -> Duration

Returns the builder’s configured read timeout.

source

pub fn write_timeout(&mut self, write_timeout: Duration) -> &mut Self

Sets the write timeout.

This timeout applies to socket-level write attempts.

Defaults to 5 minutes.

source

pub fn get_write_timeout(&self) -> Duration

Returns the builder’s configured write timeout.

source

pub fn backoff_slot_size(&mut self, backoff_slot_size: Duration) -> &mut Self

Sets the backoff slot size.

This is the upper bound on the initial delay before retrying a request. It grows exponentially as additional attempts are made for a given request.

Defaults to 250 milliseconds.

source

pub fn get_backoff_slot_size(&self) -> Duration

Returns the builder’s configured backoff slot size.

source

pub fn max_num_retries(&mut self, max_num_retries: u32) -> &mut Self

Sets the maximum number of times a request attempt will be retried before giving up.

Defaults to 4.

source

pub fn get_max_num_retries(&self) -> u32

Returns the builder’s configured maximum number of retries.

source

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

Sets the client’s internal rate limiting behavior.

Defaults to ClientQos::Enabled.

source

pub fn get_client_qos(&self) -> ClientQos

Returns the builder’s configured internal rate limiting behavior.

source

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

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

Defaults to ServerQos::AutomaticRetry.

source

pub fn get_server_qos(&self) -> ServerQos

Returns the builder’s configured server QoS behavior.

source

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

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

Defaults to ServiceError::WrapInNewError.

source

pub fn get_service_error(&self) -> ServiceError

Returns the builder’s configured service error handling behavior.

source

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

Sets the client’s 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 builder’s configured idempotency handling behavior.

source

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

Sets the client’s strategy for selecting a node for a request.

Defaults to NodeSelectionStrategy::PinUntilError.

source

pub fn get_node_selection_strategy(&self) -> NodeSelectionStrategy

Returns the builder’s 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 builder’s configured metric 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 builder’s configured host metrics registry.

source

pub fn rng_seed(&mut self, rng_seed: u64) -> &mut Self

Sets a seed used to initialize the client’s random number generators.

Several components of the client rely on entropy. If set, the client will use the seed to initialize its internal random number generators such that clients created with the same configuration will produce the same behavior.

Defaults to no seed.

source

pub fn get_rng_seed(&self) -> Option<u64>

Returns the builder’s configured RNG seed.

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 builder’s configured blocking handle.

source

pub fn with_raw_client_builder<U>(self, raw_client_builder: U) -> Builder<U>

Sets the raw client builder.

Defaults to DefaultRawClientBuilder.

source

pub fn get_raw_client_builder(&self) -> &T

Returns the builder’s configured raw client builder.

source§

impl<T> Builder<T>where T: BuildRawClient,

source

pub fn build(&self) -> Result<Client<T::RawClient>, Error>

Creates a new Client.

Panics

Panics if service or user_agent is not set.

source

pub fn build_blocking(&self) -> Result<Client<T::RawClient>, Error>

Creates a new blocking::Client.

Panics

Panics if service or user_agent is not set.

Trait Implementations§

source§

impl Default for Builder

source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T = DefaultRawClientBuilder> !RefUnwindSafe for Builder<T>

§

impl<T> Send for Builder<T>where T: Send,

§

impl<T> Sync for Builder<T>where T: Sync,

§

impl<T> Unpin for Builder<T>where T: Unpin,

§

impl<T = DefaultRawClientBuilder> !UnwindSafe for Builder<T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

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