pub struct ClientBuilder { /* private fields */ }Expand description
Builds a Client.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new(config: Config) -> ClientBuilder
pub fn new(config: Config) -> ClientBuilder
A builder over a config, with nothing else decided.
Sourcepub fn token_provider(
self,
provider: impl TokenProvider + 'static,
) -> ClientBuilder
pub fn token_provider( self, provider: impl TokenProvider + 'static, ) -> ClientBuilder
Sends Authorization: Bearer from a token provider.
Sourcepub fn access_token(self, token: impl Into<SensitiveString>) -> ClientBuilder
pub fn access_token(self, token: impl Into<SensitiveString>) -> ClientBuilder
Sends Authorization: Bearer with a fixed access token.
Sourcepub fn session_token(self, token: impl Into<SensitiveString>) -> ClientBuilder
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.
Sourcepub fn auth_strategy(
self,
strategy: impl AuthStrategy + 'static,
) -> ClientBuilder
pub fn auth_strategy( self, strategy: impl AuthStrategy + 'static, ) -> ClientBuilder
Puts credentials on with something of the caller’s own.
Sourcepub fn http_client(self, http: impl HttpClient + 'static) -> ClientBuilder
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.
Sourcepub fn user_agent(self, user_agent: impl Into<String>) -> ClientBuilder
pub fn user_agent(self, user_agent: impl Into<String>) -> ClientBuilder
Replaces the User-Agent.
Sourcepub fn timeout(self, timeout: Duration) -> ClientBuilder
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.
Sourcepub fn max_attempts(self, max_attempts: u32) -> ClientBuilder
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.
Sourcepub fn base_delay(self, base_delay: Duration) -> ClientBuilder
pub fn base_delay(self, base_delay: Duration) -> ClientBuilder
The first backoff for a raw call.
Sourcepub fn max_delay(self, max_delay: Duration) -> ClientBuilder
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.
Sourcepub fn max_retry_after(self, max_retry_after: Duration) -> ClientBuilder
pub fn max_retry_after(self, max_retry_after: Duration) -> ClientBuilder
The longest Retry-After the client sits out before handing the answer back.
Sourcepub fn max_jitter(self, max_jitter: Duration) -> ClientBuilder
pub fn max_jitter(self, max_jitter: Duration) -> ClientBuilder
The most random time added to a backoff. Zero makes the waits exact.
Sourcepub fn max_pages(self, max_pages: usize) -> ClientBuilder
pub fn max_pages(self, max_pages: usize) -> ClientBuilder
How many pages a walk reads before stopping.
Sourcepub fn max_response_body_bytes(self, bytes: usize) -> ClientBuilder
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.
Sourcepub fn cache(self, cache: impl ResponseCache + 'static) -> ClientBuilder
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.
Sourcepub fn hooks(self, hooks: impl Hooks + 'static) -> ClientBuilder
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§impl ClientBuilder
impl ClientBuilder
Sourcepub fn resilience(self, config: ResilienceConfig) -> ClientBuilder
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.
Sourcepub fn circuit_breaker(self, config: CircuitBreakerConfig) -> ClientBuilder
pub fn circuit_breaker(self, config: CircuitBreakerConfig) -> ClientBuilder
Installs the circuit breaker alone.
Sourcepub fn bulkhead(self, config: BulkheadConfig) -> ClientBuilder
pub fn bulkhead(self, config: BulkheadConfig) -> ClientBuilder
Installs the bulkhead alone.
Sourcepub fn rate_limit(self, config: RateLimitConfig) -> ClientBuilder
pub fn rate_limit(self, config: RateLimitConfig) -> ClientBuilder
Installs the rate limiter alone.