NAME
Hypersonic::UA::Pool - Connection pool for Hypersonic::UA
SYNOPSIS
# Connection pooling is automatic in Hypersonic::UA
# This module provides the internal implementation
# Initialize pool
Hypersonic::UA::Pool::init($max_per_host, $max_total, $idle_timeout);
# Get connection from pool
my $fd = Hypersonic::UA::Pool::get($host, $port, $tls);
# Return connection to pool
Hypersonic::UA::Pool::put($host, $port, $tls, $fd);
# Get pool statistics
my $stats = Hypersonic::UA::Pool::stats();
DESCRIPTION
Hypersonic::UA::Pool manages HTTP keep-alive connection pooling for Hypersonic::UA. It maintains a pool of open TCP connections organized by host:port:tls, enabling connection reuse for improved performance.
FUNCTIONS
init
Hypersonic::UA::Pool::init($max_per_host, $max_total, $idle_timeout);
Initialize the connection pool. Defaults:
max_per_host = 6 (connections per host:port:tls)
max_total = 100 (total connections)
idle_timeout = 60 (seconds before idle connection expires)
get
my $fd = Hypersonic::UA::Pool::get($host, $port, $tls);
Get a pooled connection for the given host:port:tls. Returns undef if no connection is available (pool miss).
put
my $ok = Hypersonic::UA::Pool::put($host, $port, $tls, $fd);
Return a connection to the pool. The connection will be closed if:
Pool is at max capacity
Host bucket is at max_per_host capacity (oldest evicted)
remove
Hypersonic::UA::Pool::remove($host, $port, $tls, $fd);
Remove a specific connection from the pool (e.g., after error).
clear
Hypersonic::UA::Pool::clear();
Close all pooled connections.
prune
my $count = Hypersonic::UA::Pool::prune();
Remove expired connections (past idle_timeout). Returns count pruned.
stats
my $stats = Hypersonic::UA::Pool::stats();
Get pool statistics:
{
total_connections => 42,
hosts_tracked => 5,
max_per_host => 6,
max_total => 100,
idle_timeout => 60,
hits => 1234,
misses => 56,
hit_rate => 0.956,
}
is_alive
my $alive = Hypersonic::UA::Pool::is_alive($fd);
Check if a socket is still alive (not closed by peer).
AUTHOR
lnation <email@lnation.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.