pub struct ClientConfig {
pub base_url: String,
pub timeout_ms: u64,
pub pool_size: usize,
pub retry_config: Option<RetryConfig>,
pub max_concurrent: Option<usize>,
pub http_transport: Option<Arc<dyn HttpTransport>>,
pub runtime: Option<Arc<dyn Runtime>>,
/* private fields */
}Expand description
The transport settings a client builder holds: the base URL, the timeout, the connection pool, the retry schedule, the concurrency budget, the runtime and the transport.
A venue’s builder holds one, generates its setters with
client_config_setters!, and builds its
HttpClient from http_builder,
adding the throttle and the retry policy it installs itself, the throttle
on the runtime runtime_or_default names. The
config holds no throttle, policy or gzip setting, since those belong to
the venue.
Fields§
§base_url: StringThe API’s base URL.
timeout_ms: u64Request timeout in milliseconds.
pool_size: usizeIdle connections kept per host.
retry_config: Option<RetryConfig>The retry schedule; None keeps RetryConfig::default.
max_concurrent: Option<usize>In-flight requests allowed; None keeps the client’s default.
http_transport: Option<Arc<dyn HttpTransport>>The transport every attempt is sent on; None keeps the target’s
default, which is built from the timeout, the pool size and the
client’s gzip (ReqwestTransport on the native targets).
runtime: Option<Arc<dyn Runtime>>The runtime every wait, clock read and spawn of the client goes
through; None takes polyoxide_rt::default_runtime.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(base_url: impl Into<String>, default_max_concurrent: usize) -> Self
pub fn new(base_url: impl Into<String>, default_max_concurrent: usize) -> Self
A config for base_url with core’s default timeout and pool size, no
retry config of its own, and default_max_concurrent in-flight
requests unless max_concurrent is set.
Sourcepub fn http_builder(&self) -> HttpClientBuilder
pub fn http_builder(&self) -> HttpClientBuilder
An HttpClientBuilder for the base URL, with the timeout, the pool
size, the concurrency (the set value, else the client’s default), the
runtime, the transport and the retry config if they are set. It sets
no throttle, policy or gzip.
Sourcepub fn runtime_or_default(&self) -> Arc<dyn Runtime> ⓘ
pub fn runtime_or_default(&self) -> Arc<dyn Runtime> ⓘ
The runtime this config names, else the target’s default
(polyoxide_rt::default_runtime).
A venue’s build calls it once and gives the result both to
HttpClientBuilder::runtime and
to the throttle it installs, so the client and its throttle keep time
on one runtime.