Deadfinder::HttpClient::ConnectionPool
Bounded pool of idle keep-alive clients, keyed by origin (plus the connection settings that shape the client, so a differently-configured run can never pick up a client built for the previous one).
Borrow/return, not share: checkout removes the client from the pool,
so it is invisible to every other fiber until checkin puts it back.
That exclusivity is the whole point — Crystal fibers yield on every socket
read, so two fibers holding one HTTP::Client would interleave their
requests on a single connection and read each other's responses.
Constants
Servers close idle keep-alive connections after a few seconds. Handing out one the peer already dropped costs a failed request plus a reconnect, so anything idle longer than this is closed on borrow.
Idle clients kept per origin. Chosen to sit above the default concurrency (50) so a single-host scan — the case the pool exists for — reuses every worker's connection instead of re-handshaking most of them.
Idle clients kept across all origins. A scan whose links fan out over hundreds of hosts would otherwise retain a few sockets per host and run the process out of file descriptors; past this point the least recently used connection is closed to make room.
Constructors
Instance methods
Returns a client the caller now owns exclusively, or nil when the pool has nothing fresh for this origin.
A client whose request raised is never returned to the pool: the connection may be half-written or half-read, and reusing it would desynchronize the next response.