pub struct HttpClientBuilder { /* private fields */ }Expand description
Builder for configuring HTTP clients.
Provides a consistent way to configure HTTP clients across all API crates with sensible defaults.
§Example
use polyoxide_core::HttpClientBuilder;
let client = HttpClientBuilder::new("https://api.example.com")
.timeout_ms(60_000)
.pool_size(20)
.build()
.unwrap();Implementations§
Source§impl HttpClientBuilder
impl HttpClientBuilder
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
Create a new HTTP client builder with the given base URL.
Sourcepub fn timeout_ms(self, timeout: u64) -> Self
pub fn timeout_ms(self, timeout: u64) -> Self
Set request timeout in milliseconds.
Default: 30,000ms (30 seconds)
Sourcepub fn pool_size(self, size: usize) -> Self
pub fn pool_size(self, size: usize) -> Self
Set connection pool size per host.
Default: 10 connections
Sourcepub fn with_rate_limiter(self, limiter: RateLimiter) -> Self
pub fn with_rate_limiter(self, limiter: RateLimiter) -> Self
Set a rate limiter for this client.
Sourcepub fn with_retry_config(self, config: RetryConfig) -> Self
pub fn with_retry_config(self, config: RetryConfig) -> Self
Set retry configuration for 429 responses.
Sourcepub fn with_max_concurrent(self, max: usize) -> Self
pub fn with_max_concurrent(self, max: usize) -> Self
Set the maximum number of concurrent in-flight HTTP requests.
Prevents Cloudflare 1015 rate-limit errors caused by request bursts when many callers share the same client concurrently.
Sourcepub fn gzip(self, enabled: bool) -> Self
pub fn gzip(self, enabled: bool) -> Self
Ask for gzip-compressed responses and decode them.
Off by default. The workspace enables reqwest’s gzip feature for
hosts with large bodies (Binance’s exchangeInfo is 1.15 MB raw and
51 KB gzipped), and with the feature on reqwest would otherwise send
Accept-Encoding: gzip from every client. Leaving it off keeps every
other crate’s requests byte-identical to before the feature existed.
Sourcepub fn build(self) -> Result<HttpClient, ApiError>
pub fn build(self) -> Result<HttpClient, ApiError>
Build the HTTP client.