Skip to main content

HttpClientConfig

Struct HttpClientConfig 

Source
pub struct HttpClientConfig {
    pub implementation: HttpImpl,
    pub driver: Config,
    pub pool: usize,
    pub request_timeout_ms: u32,
    pub buf_size: usize,
    pub background_connect: bool,
    pub curl_drive: CurlDrive,
    pub curl_ca_file: Option<String>,
    pub curl_allow_non_idempotent_methods: bool,
    pub connect_gate: bool,
    pub reconnect_seed: u64,
}
Expand description

HttpClient settings.

Fields§

§implementation: HttpImpl

The implementation.

§driver: Config

Native: the loop backend for the pool’s driver. Both implementations take TCP keepalive, TCP_USER_TIMEOUT and the quick-ACK route check’s policy from it (driver.quickack_check, see crate::route): libcurl’s connections are checked from its pre-request callback (libcurl 7.80 or later).

§pool: usize

Connections kept warm (native) or the most libcurl may use at once.

§request_timeout_ms: u32

Time from sending a request to its complete response, in milliseconds.

§buf_size: usize

Native: receive buffer per connection (must hold the largest response).

§background_connect: bool

Native: open connections on the driver’s helper thread (Driver::connect_background), keeping handshake CPU off the loop. In a process that may use the polling CPU only (a pod with one CPU, crate::placement) HttpClient::new then fails with Error::Cpu, unless driver.inline_connect_fallback is set: the pool then opens connections on the loop, as with false.

§curl_drive: CurlDrive

Curl: how libcurl is driven.

§curl_ca_file: Option<String>

Curl: a CA bundle file instead of the system store. (Native trust comes from the rustls configuration passed to HttpClient::new.)

§curl_allow_non_idempotent_methods: bool

Curl: accept POST, PUT, PATCH and every method other than GET, HEAD, OPTIONS and DELETE. Off by default: libcurl sends a request again, up to 5 times, when the reused connection it went out on dies before any reply byte, so an order could run twice. Off, such a request fails with Error::CurlResend. Send orders through the native client, which never re-sends.

§connect_gate: bool

Native: every pool connect waits for ClientHandler::connect_gate, the first ones included, so new opens nothing and HttpClient::poll refuses (Error::Config). For a venue that limits connects per IP. Give the pool a budget bucket of its own: venues’ connect limits count WebSocket connects, not HTTP ones. Off (default): new opens every connection at once.

§reconnect_seed: u64

Native: the seed of the reconnect delays’ jitter; 0 picks one at random. A fixed seed gives the same delays every run (tests).

Implementations§

Source§

impl HttpClientConfig

Source

pub const fn new(implementation: HttpImpl) -> Self

Defaults: native, recv-busy, a pool of 2, background connects.

Trait Implementations§

Source§

impl Clone for HttpClientConfig

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 HttpClientConfig

Source§

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

Formats the value using the given formatter. 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> 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.