silk/http_connection_pool
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.
Bounded local HTTP/1 connection pooling with explicit ownership and deterministic eviction.
Details
A pool preallocates every shared slot before publication. Shared callbacks only scan and move already-owned values; clock reads, connector calls, user callbacks, allocation, and physical close operations remain outside shared access. Capacity is fail-fast and local to one scheduler thread. There is no waiter queue, background expiry worker, request replay, HTTP/2 coalescing, or WebSocket pooling.
Import as Pool with import silk.http_connection_pool { Pool }.
Public declarations: 27.
DEFAULT_MAX_TOTAL
pub const DEFAULT_MAX_TOTAL: usizeDefault maximum number of opening, leased, and idle connections together.
DEFAULT_MAX_IDLE
pub const DEFAULT_MAX_IDLE: usizeDefault maximum number of retained idle connections.
DEFAULT_MAX_PER_ORIGIN
pub const DEFAULT_MAX_PER_ORIGIN: usizeDefault maximum number of connections for one normalized original origin.
DEFAULT_IDLE_TIMEOUT_NANOSECONDS
pub const DEFAULT_IDLE_TIMEOUT_NANOSECONDS: u64Default idle lifetime in nanoseconds.
MAX_TOTAL
pub const MAX_TOTAL: usizeHard maximum total pool capacity.
Config
pub struct ConfigFinite pool limits admitted before shared state is allocated.
Field maxTotal
pub maxTotal: usizeMaximum opening, leased, and idle count.
Field maxIdle
pub maxIdle: usizeMaximum retained idle count. Zero disables retention.
Field maxPerOrigin
pub maxPerOrigin: usizeMaximum count for one normalized original origin.
Field idleTimeoutNanoseconds
pub idleTimeoutNanoseconds: u64Positive idle lifetime on the pool's monotonic timeline.
Associated function Config.defaults
pub fn defaults() -> ConfigReturns the finite standard limits: 32 total, 16 idle, 8 per origin, and 30 seconds idle.
Implementation Copy for Config
impl Copy for ConfigConfigField
pub enum ConfigFieldThe configuration field rejected before pool publication.
MaxTotal
MaxTotal = 0maxTotal is outside 1 through 1024.
MaxIdle
MaxIdle = 1maxIdle exceeds maxTotal.
MaxPerOrigin
MaxPerOrigin = 2maxPerOrigin is zero or exceeds maxTotal.
IdleTimeout
IdleTimeout = 3The idle duration is zero.
PoolError
pub union PoolErrorA pool admission, capacity, lifecycle, or checked-accounting failure.
InvalidConfig
PoolError.InvalidConfig { field: ConfigField }: PoolErrorConfiguration was rejected before allocation or publication.
Field field
pub field: ConfigFieldThe configuration field whose value is outside its admitted range.
PoolFull
PoolError.PoolFull: PoolErrorNo legal idle eviction can satisfy global and per-origin capacity.
PoolClosed
PoolError.PoolClosed: PoolErrorThe root pool has closed; surviving handles cannot acquire or publish.
ContextMismatch
PoolError.ContextMismatch: PoolErrorThe key is incompatible with the handle's frozen acquisition/security context.
OpeningExpired
PoolError.OpeningExpired: PoolErrorOpening could not begin or completed at or after its effective acquisition deadline.
Implementation Copy for PoolError
impl Copy for PoolErrorCounts
pub struct CountsA synchronous snapshot of bounded shared accounting.
Field opening
pub opening: usizeConnections whose capacity is reserved while opening.
Field leased
pub leased: usizeConnections currently lent to callbacks.
Field idle
pub idle: usizeComplete connections retained for later reuse.
Field total
pub total: usizeopening + leased + idle.
Field closed
pub closed: boolWhether root ownership has closed the pool.
Implementation Copy for Counts
impl Copy for CountsCollection
pub struct CollectionResult of explicit lazy expiry collection.
Field expired
pub expired: usizeNumber of expired idle owners physically closed by this call.
Implementation Copy for Collection
impl Copy for CollectionCheckoutSource
pub enum CheckoutSourceWhether checkout selected an idle owner or opened a new one.
Reused
Reused = 0A compatible most-recently-returned idle owner was selected.
Opened
Opened = 1Capacity was reserved and the immutable connector opened a new owner.
CheckoutResult
pub struct CheckoutResult<A>A successful callback value paired with its checkout source.
Field value
pub value: AThe callback result.
Field source
pub source: CheckoutSourceHow the exclusive owner was obtained.
PoolKey
pub interface PoolKey<CopyError, ?CopyRequirements>Compile-time contract for an independently owned conservative connection key.
Operation copy
effect<'env> fn copy<'life2: 'env, 'env>(key: &'life2 Self) -> Self ! CopyError ? CopyRequirementsCopies the complete key before entering shared state.
Operation equals
fn equals<'life2, 'life3>(left: &'life2 Self, right: &'life3 Self) -> boolReports exact route, provider, and security compatibility.
Operation sameOrigin
fn sameOrigin<'life2, 'life3>(left: &'life2 Self, right: &'life3 Self) -> boolReports normalized original-origin equality for the per-origin cap.
PoolContextCopy
pub interface PoolContextCopy<CopyError, ?CopyRequirements>Fallible bounded-copy contract for immutable context retained beside shared mutable state.
Operation copy
effect<'env> fn copy<'life2: 'env, 'env>(context: &'life2 Self) -> Self ! CopyError ? CopyRequirementsFallibly copies all bounded context before a new Shared alias is published.
PoolContext
pub interface PoolContext<K, P, AcquisitionError, ?AcquisitionRequirements>Immutable acquisition context retained beside, never inside, shared mutable state.
Operation accepts
fn accepts<'life4, 'life5>(context: &'life4 Self, key: &'life5 K) -> boolChecks key compatibility without allocation, clock access, or transport contact.
Operation acquire
effect<'env> fn acquire<'life4: 'env, 'life5: 'env, 'env>(context: &'life4 Self, key: &'life5 K, deadline: silk/option.Option<silk/system_clock.Instant>) -> silk/http_client.Connection<P> ! AcquisitionError ? AcquisitionRequirementsOpens one complete HTTP owner under only the effective acquisition deadline.
PoolHandler
pub interface PoolHandler<K, P, C, A, E, ?R>A higher-ranked root-pool callback whose pool borrow cannot escape.
Operation handle
effect<'scope> fn handle<'scope: 'scope>(handler: Self, pool: &'scope mut silk/http_connection_pool.Pool<K, P, C>) -> A ! E ? RUses one root pool until success, failure, or structured cancellation closes it.
EndpointIdentity
pub union EndpointIdentityExact endpoint identity retained by the standard conservative key.
Direct
EndpointIdentity.Direct: EndpointIdentityDirect network contact, conservatively partitioned by the original origin.
Proxy
EndpointIdentity.Proxy { route: RouteKey }: EndpointIdentityA sealed JUL-199 route, including mode, endpoint, original origin, and credential identity.
Field route
pub route: RouteKeyThe sealed proxy route identity used to partition reusable connections.
Unix
EndpointIdentity.Unix { path: Bytes }: EndpointIdentityDirect Unix-domain contact with an exact owned pathname.
ConnectionKey
pub struct ConnectionKeyThe standard conservative key used by direct native and proxy-aware pool contexts.
Details
Provider representation, HTTP policy, TLS verification/trust/ALPN policy, and connector policy
belong to the constructor-sealed PoolContext. This key retains only request-visible route
identity; direct resolution results never establish equivalence.
Associated function ConnectionKey.direct
pub fn direct(originalOrigin: Origin) -> ConnectionKeyCreates a direct network key from the normalized original origin without allocation.
Associated function ConnectionKey.proxy
pub fn proxy(route: RouteKey) -> ConnectionKeyCreates a proxy-aware key from the sealed JUL-199 route identity.
Associated function ConnectionKey.unix
pub effect<'life0> fn unix<'life0>(originalOrigin: Origin, path: &'life0 [u8]) -> ConnectionKey ! OutOfMemoryError ? &mut AllocatorCopies one exact Unix pathname into a conservative direct key.
Method ConnectionKey.origin
pub fn origin<'life0>(self: &'life0 ConnectionKey) -> OriginReturns the normalized original origin used for per-origin capacity.
Method ConnectionKey.isDirect
pub fn isDirect<'life0>(self: &'life0 ConnectionKey) -> boolReturns whether this key selects direct native contact for its original origin.
Method ConnectionKey.matchesUnixPath
pub fn matchesUnixPath<'life0, 'life1>(self: &'life0 ConnectionKey, path: &'life1 [u8]) -> boolReturns whether this key selects the exact supplied Unix path for its original origin.
Implementation silk/http_connection_pool.PoolKey<silk/allocator.OutOfMemoryError, ? &mut silk/allocator.Allocator> for ConnectionKey
impl silk/http_connection_pool.PoolKey<silk/allocator.OutOfMemoryError, ? &mut silk/allocator.Allocator> for ConnectionKeyOperation copy
copy = ConnectionKey.impl@4.copyOperation equals
equals = ConnectionKey.impl@4.equalsOperation sameOrigin
sameOrigin = ConnectionKey.impl@4.sameOriginPool
pub struct Pool<K, P, C>The scoped root owner. Use withPool so closure runs on every structured exit.
Method Pool.handle
pub fn handle<K, P, C, 'life3>(self: &'life3 Pool<K, P, C>) -> &'life3 silk/http_connection_pool.Handle<K, P, C>Borrows the root handle without publishing another Shared alias.
Handle
pub struct Handle<K, P, C>A fallibly copied local handle sharing only preallocated mutable slot state.
context
pub fn context<'handle, K, P, C>(handle: &'handle silk/http_connection_pool.Handle<K, P, C>) -> &'handle CBorrows one handle's immutable acquisition context without exposing shared slot state.
withPool
pub effect<'env> fn withPool<K, P, C: 'env, A, E, ?R, H: 'env, 'env>(config: Config, context: C, handler: H) -> A ! E | PoolError | OutOfMemoryError ? R | &mut Allocator where &mut P provides &HttpTransport from &mut HttpTransportConstructs one finite pool, lends its root, and closes it on every structured exit.
copyHandle
pub effect<'env> fn copyHandle<K: 'env, P: 'env, CopyError, ?CopyRequirements, C: 'env, 'life5: 'env, 'env>(handle: &'life5 silk/http_connection_pool.Handle<K, P, C>) -> silk/http_connection_pool.Handle<K, P, C> ! CopyError ? CopyRequirementsCopies immutable context before cloning Shared state, so copy failure publishes no alias.
counts
pub fn counts<K, P, C, 'life3>(handle: &'life3 silk/http_connection_pool.Handle<K, P, C>) -> CountsInspects exact shared accounting without allocating or consulting the clock.
withConnection
pub effect<'env> fn withConnection<P: 'env, A, E, KeyCopyError, AcquisitionError, ?KeyCopyRequirements, ?AcquisitionRequirements, ?CallbackRequirements, K: 'env, C: 'env, H: 'env, 'life11: 'env, 'life12: 'env, 'env>(handle: &'life11 silk/http_connection_pool.Handle<K, P, C>, key: &'life12 K, requestDeadline: silk/option.Option<silk/system_clock.Instant>, acquisitionDeadline: silk/option.Option<silk/system_clock.Instant>, handler: H) -> silk/http_connection_pool.CheckoutResult<A> ! E | KeyCopyError | AcquisitionError | PoolError ? KeyCopyRequirements | AcquisitionRequirements | CallbackRequirements | &mut MonotonicClock where &mut P provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random, &mut P provides &HttpTransport from &mut HttpTransportChecks out exactly one owner, lends it to handler, and publishes it only when client-eligible.
Details
Acquisition uses the earlier of requestDeadline and acquisitionDeadline; the connector must
construct pooled owners without retaining that bound. The handler remains responsible for
passing the unchanged request deadline to each HTTP exchange. Failures and cancellation close
instead of replaying the request.
collect
pub effect<'env> fn collect<K: 'env, P: 'env, C: 'env, 'life3: 'env, 'env>(handle: &'life3 silk/http_connection_pool.Handle<K, P, C>) -> Collection ? &mut MonotonicClock where &mut P provides &HttpTransport from &mut HttpTransportSamples the monotonic clock once, lazily removes every expired idle owner, and closes outside Shared.
close
pub effect<'env> fn close<K: 'env, P: 'env, C: 'env, 'life3: 'env, 'env>(pool: &'life3 mut silk/http_connection_pool.Pool<K, P, C>) -> () ! ClientError where &mut P provides &HttpTransport from &mut HttpTransportMarks the pool closed idempotently and physically closes all currently idle owners outside Shared.