pub struct Limits {
pub max_connections: Option<usize>,
pub max_connections_per_host: Option<usize>,
pub max_in_flight_requests: Option<usize>,
pub max_in_flight_requests_per_origin: Option<usize>,
pub max_idle_connections: Option<usize>,
pub max_idle_connections_per_host: Option<usize>,
pub keepalive_expiry: Option<Duration>,
}Expand description
Resource limits for the connection pool.
Distinguishes between logical request concurrency (pool permits, one per in-flight request) and physical connection behavior (Hyper’s internal idle pool).
§Logical vs physical
max_in_flight_requests/max_in_flight_requests_per_originbound logical requests. Under H1 one request usually owns its connection slot; under H2/H3 many requests multiplex over one connection/QUIC session while each still holds a permit.max_idle_connections*/keepalive_expiryare physical idle-pool policy passed to Hyper, not concurrency bounds.
max_connections / max_connections_per_host are compatibility
aliases for the pre-1.0 line (same semantics as the new names; the
HTTPX facade keeps Limits(max_connections=...) unchanged). When both
alias and new name are set, the new name wins.
Fields§
§max_connections: Option<usize>Maximum concurrent logical requests (pool permits).
Compatibility alias for max_in_flight_requests. Maps to pool
max_connections.
max_connections_per_host: Option<usize>Maximum concurrent logical requests per origin.
Compatibility alias for max_in_flight_requests_per_origin. Maps
to pool max_connections_per_host.
max_in_flight_requests: Option<usize>Maximum concurrent in-flight requests (logical, preferred name).
One permit per request, not one TCP connection. H1/H2/H3 examples:
H1 serializes one request per connection; H2 multiplexes many
streams over one TCP connection up to the server’s
SETTINGS_MAX_CONCURRENT_STREAMS; H3 multiplexes over QUIC with
bidi streams derived from the per-origin limit.
max_in_flight_requests_per_origin: Option<usize>Maximum concurrent in-flight requests per origin (logical, preferred name).
max_idle_connections: Option<usize>Maximum number of idle (kept-alive) connections. Maps to hyper’s pool idle connection limit (physical).
max_idle_connections_per_host: Option<usize>Maximum number of idle connections per host (physical). Maps to hyper’s pool per-host idle limit.
keepalive_expiry: Option<Duration>Duration after which idle connections are closed (physical).
Implementations§
Source§impl Limits
impl Limits
Sourcepub fn effective_max_in_flight(&self) -> Option<usize>
pub fn effective_max_in_flight(&self) -> Option<usize>
Effective global logical-request limit (new name wins).
Sourcepub fn effective_max_in_flight_per_origin(&self) -> Option<usize>
pub fn effective_max_in_flight_per_origin(&self) -> Option<usize>
Effective per-origin logical-request limit (new name wins).
Source§impl Limits
impl Limits
Sourcepub fn compat() -> Self
pub fn compat() -> Self
Create HTTPX-compatible limits.
HTTPX 0.28.1 defaults to 100 total connections with a 5-second keepalive expiry. Per-host idle connections default to 20. No per-host concurrency limit is set.
§Examples
use eggfetch_core::Limits;
let limits = Limits::compat();
assert_eq!(limits.max_connections, Some(100));
assert!(limits.max_connections_per_host.is_none());
assert_eq!(limits.max_idle_connections, Some(20));
assert_eq!(limits.max_idle_connections_per_host, Some(20));
assert_eq!(limits.keepalive_expiry, Some(std::time::Duration::from_secs(5)));Sourcepub fn native() -> Self
pub fn native() -> Self
Create unlimited defaults (all None).
No concurrency limits or idle connection caps are applied. Idle connections are never proactively closed.
§Examples
use eggfetch_core::Limits;
let limits = Limits::native();
assert!(limits.max_connections.is_none());
assert!(limits.max_connections_per_host.is_none());
assert!(limits.max_idle_connections.is_none());
assert!(limits.max_idle_connections_per_host.is_none());
assert!(limits.keepalive_expiry.is_none());