Skip to main content

ClientBuilder

Struct ClientBuilder 

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

Builds a Client.

Implementations§

Source§

impl ClientBuilder

Source

pub fn new(config: Config) -> ClientBuilder

A builder over a config, with nothing else decided.

Source

pub fn token_provider( self, provider: impl TokenProvider + 'static, ) -> ClientBuilder

Sends Authorization: Bearer from a token provider.

Source

pub fn access_token(self, token: impl Into<SensitiveString>) -> ClientBuilder

Sends Authorization: Bearer with a fixed access token.

Source

pub fn session_token(self, token: impl Into<SensitiveString>) -> ClientBuilder

Sends Cookie: session_token= with a fixed session token, as a magic-link login hands out.

Source

pub fn auth_strategy( self, strategy: impl AuthStrategy + 'static, ) -> ClientBuilder

Puts credentials on with something of the caller’s own.

Source

pub fn http_client(self, http: impl HttpClient + 'static) -> ClientBuilder

Replaces the HTTP client every request goes out on. The one supplied must not follow redirects; see HttpClient. The timeout set on the builder is then ignored — a timeout belongs to the client that can enforce it.

Source

pub fn user_agent(self, user_agent: impl Into<String>) -> ClientBuilder

Replaces the User-Agent.

Source

pub fn timeout(self, timeout: Duration) -> ClientBuilder

How long the HTTP client the SDK ships gives an answer to arrive. It has no effect on one supplied with ClientBuilder::http_client.

Source

pub fn max_attempts(self, max_attempts: u32) -> ClientBuilder

How many times a raw call is sent, the first attempt included, and the most a modelled route may be sent whatever the behavior model says. One sends everything once; zero reads as one.

Source

pub fn base_delay(self, base_delay: Duration) -> ClientBuilder

The first backoff for a raw call.

Source

pub fn max_delay(self, max_delay: Duration) -> ClientBuilder

The longest wait between attempts, whatever the backoff or the route’s own base delay would have made it.

Source

pub fn max_retry_after(self, max_retry_after: Duration) -> ClientBuilder

The longest Retry-After the client sits out before handing the answer back.

Source

pub fn max_jitter(self, max_jitter: Duration) -> ClientBuilder

The most random time added to a backoff. Zero makes the waits exact.

Source

pub fn max_pages(self, max_pages: usize) -> ClientBuilder

How many pages a walk reads before stopping.

Source

pub fn max_response_body_bytes(self, bytes: usize) -> ClientBuilder

The most an answer may deliver before the client refuses to hold it. Zero asks for the default: the cap cannot be lifted, only moved.

Source

pub fn cache(self, cache: impl ResponseCache + 'static) -> ClientBuilder

Caches JSON reads by ETag. Without this, config.cache_enabled decides whether a FileCache in config.cache_dir is used.

Source

pub fn hooks(self, hooks: impl Hooks + 'static) -> ClientBuilder

Reports every operation and every request the client makes. Several sets of hooks go on as one with crate::observability::ChainHooks.

Source

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

Builds the client, refusing a base URL that would carry credentials over plain HTTP anywhere but this machine.

Source§

impl ClientBuilder

Source

pub fn resilience(self, config: ResilienceConfig) -> ClientBuilder

Installs the layers the config asks for, keeping whatever hooks the builder already carries: they still hear about every operation and request.

Source

pub fn circuit_breaker(self, config: CircuitBreakerConfig) -> ClientBuilder

Installs the circuit breaker alone.

Source

pub fn bulkhead(self, config: BulkheadConfig) -> ClientBuilder

Installs the bulkhead alone.

Source

pub fn rate_limit(self, config: RateLimitConfig) -> ClientBuilder

Installs the rate limiter alone.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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