Skip to main content

CachekitIOBuilder

Struct CachekitIOBuilder 

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

Builder for CachekitIO.

Implementations§

Source§

impl CachekitIOBuilder

Source

pub fn api_key(self, key: impl Into<String>) -> Self

Set the API key (required).

Source

pub fn api_url(self, url: impl Into<String>) -> Self

Override the API base URL (default: https://api.cachekit.io).

Source

pub fn allow_custom_host(self, allow: bool) -> Self

Allow non-standard hostnames (e.g. custom proxies). Private IPs are still blocked.

Source

pub fn metrics_provider(self, provider: MetricsProvider) -> Self

Override the source of the X-CacheKit-* telemetry headers.

Not needed for normal use: CacheKitBuilder::build attaches the client’s own live counters to any backend without one. Set this only to report numbers from somewhere else; it takes precedence.

Source

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

Per-attempt timeout for every request but a write: get, exists, health, the TTL calls and the lock calls (default 5 s, the protocol’s CACHEKIT_TIMEOUT). It runs from send through the last byte of the response body and surfaces as BackendErrorKind::Timeout. A new connection’s DNS, TCP and TLS count against it, and never take more than 5 s whatever the budget.

The budget is per attempt. When the reliability stack wraps this backend through CacheKitBuilder::reliability, each retry gets a fresh budget, so with the default 3 attempts one read can take about three budgets plus backoff before it errors. Each operation that ends in a timeout counts as one failure toward opening the circuit breaker, which a tokio::time::timeout around the call does not: a cancelled call records no outcome. (CacheKit::io builds its own backend with the default budgets and also caps all attempts of a read at 5 s; a backend passed to CacheKitBuilder::backend gets no such cap.)

build rejects Duration::ZERO with CachekitError::Config.

Source

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

Per-attempt timeout for a write, set or delete (default 10 s, twice the read budget: a write carries the payload, and the service commits it before it answers). Otherwise as read_timeout: it covers the whole request, applies per attempt under the reliability stack, and counts toward the circuit breaker.

build rejects Duration::ZERO with CachekitError::Config.

Source

pub fn build(self) -> Result<CachekitIO, CachekitError>

Consume the builder and construct a CachekitIO.

§Errors

Returns an error if:

  • api_key was not set, or holds bytes an HTTP header cannot carry (a control character such as a newline).
  • the resolved URL scheme is not https, or the URL carries a query or a fragment.
  • the URL carries credentials, or its hostname is not permitted (see validate_cachekitio_url).
  • the read or write timeout is zero.

Trait Implementations§

Source§

impl Default for CachekitIOBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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<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