Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub base_url: String,
    pub model: String,
    pub provider: String,
    pub user_agent: String,
    pub connect_timeout: Duration,
    pub timeout: Duration,
    pub max_retries: u32,
    pub max_backoff: Duration,
    pub pool_size: usize,
    pub throttle_pause: Duration,
    pub backoff_scale: f64,
}
Expand description

How a Client reaches the API and how hard it tries.

Build one with Config { field: value, ..Config::default() }. Every field has a default that suits TypeSafe’s hosted endpoint.

Fields§

§base_url: String

The endpoint every request is POSTed to. DEFAULT_BASE_URL, or a gateway in front of it. The URL is used as given: a token is sent to whatever host it names.

§model: String

The model name sent in every request. DEFAULT_MODEL follows TypeSafe’s latest Jev.

§provider: String

Who serves the endpoint, for error messages only: TypeSafe, or the name of a gateway.

§user_agent: String

The User-Agent header. Defaults to this crate’s name and version.

§connect_timeout: Duration

Time allowed to open a connection.

§timeout: Duration

Time allowed for each of sending the request, waiting for the response and reading it.

§max_retries: u32

Attempts after the first for transient failures; see Error for what is transient.

§max_backoff: Duration

The longest a retry’s exponential backoff grows to. The backoff starts at half a second and doubles per attempt, up to this cap, times a random factor in [0.5, 1.5).

§pool_size: usize

Connections kept open, and the ceiling of the concurrency AdaptiveLimiter. Set it to the number of threads that will call Client::ask at once.

§throttle_pause: Duration

How long every thread waits after a throttled reply (HTTP 429 or 529) before the next attempt, times a random factor in [1, 2).

§backoff_scale: f64

Multiplies the retry backoff and any Retry-After wait. Zero makes retries immediate, which tests want; Config::throttle_pause is separate. A negative or non-finite scale also means no wait.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

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

impl PartialEq for Config

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Config

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.