Builder

Struct Builder 

Source
pub struct Builder<T = Complete>(/* private fields */);
Expand description

A builder to construct Clients and blocking::Clients.

Implementations§

Source§

impl Builder<ServiceStage>

Source

pub fn new() -> Self

Creates a new builder with default settings.

Source

pub fn service(self, service: &str) -> Builder<UserAgentStage>

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

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

Source§

impl Builder<UserAgentStage>

Source

pub fn user_agent(self, user_agent: UserAgent) -> Builder

Sets the user agent sent by this client.

Source§

impl Builder<Complete>

Source

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

Applies configuration settings from a ServiceConfig to the builder.

Source

pub fn get_service(&self) -> &str

Returns the builder’s configured service name.

Source

pub fn get_user_agent(&self) -> &UserAgent

Returns the builder’s configured user agent.

Source

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

Appends a URI to the URIs list.

Defaults to an empty list.

Source

pub fn uris(self, uris: Vec<Url>) -> 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(self, security: SecurityConfig) -> 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(self, proxy: ProxyConfig) -> 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(self, connect_timeout: Duration) -> 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(self, read_timeout: Duration) -> 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(self, write_timeout: Duration) -> 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(self, backoff_slot_size: Duration) -> 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(self, max_num_retries: u32) -> 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(self, client_qos: ClientQos) -> 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(self, server_qos: ServerQos) -> 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(self, service_error: ServiceError) -> 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(self, idempotency: Idempotency) -> 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( self, node_selection_strategy: NodeSelectionStrategy, ) -> 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(self, metrics: Arc<MetricRegistry>) -> 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(self, host_metrics: Arc<HostMetricsRegistry>) -> 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 override_host_index(self, override_host_index: usize) -> Self

Overrides the hostIndex field included in metrics.

Source

pub fn get_override_host_index(&self) -> Option<usize>

Returns the builder’s hostIndex override.

Source

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

Creates a new Client.

Source§

impl Builder<Complete>

Source

pub fn blocking_handle(self, blocking_handle: Handle) -> 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 build_blocking(&self) -> Result<Client, Error>

Creates a new blocking::Client.

Trait Implementations§

Source§

impl Default for Builder<ServiceStage>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

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

§

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> UnwindSafe for Builder<T>
where T: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,