Pool
abstract class Pool implements PoolInterface
Manage reusable connections with explicit ownership and terminal teardown.
Properties
| protected Channel | $channel | ||
| protected PoolOptionInterface | $option | ||
| protected array<int, true> | $managedConnections | ||
| protected array<int, true> | $borrowedConnections | ||
| protected int | $creating | ||
| protected bool | $closed | ||
| protected FrequencyInterface|LowFrequencyInterface|null | $frequency |
Methods
Get the pool name.
Get a connection from the pool.
Close idle connections while the total managed count exceeds the configured minimum.
Check one idle connection and discard it when unhealthy.
Close the pool and destroy every idle connection.
Determine if the pool is closed.
Get the current number of connections managed by the pool.
Get the pool configuration options.
Get the number of connections currently available in the pool.
Initialize pool options from configuration.
Create a new connection for the pool.
Pop and validate one idle connection.
Return an idle connection without changing its activity timestamps.
Destroy a managed connection and release its capacity.
Get the logger instance if available.
Convert seconds to nanoseconds without overflowing integer arithmetic.
Build a monotonic deadline without overflowing at long durations or uptimes.
Details
at line 41
__construct(Container $container, string $name, array $config = [])
Create a connection pool.
at line 54
string
getName()
Get the pool name.
at line 62
ConnectionInterface
get()
Get a connection from the pool.
at line 92
void
release(ConnectionInterface $connection)
Release a connection back to the pool.
at line 109
void
discard(ConnectionInterface $connection)
Discard a borrowed connection from the pool.
at line 118
void
flush()
Close idle connections while the total managed count exceeds the configured minimum.
at line 133
void
checkIdleConnection()
Check one idle connection and discard it when unhealthy.
at line 163
void
close()
Close the pool and destroy every idle connection.
Idempotent. Connections borrowed when closure begins are destroyed on release, and factories completing after closure destroy their orphan.
at line 189
bool
isClosed()
Determine if the pool is closed.
at line 197
int
getCurrentConnections()
Get the current number of connections managed by the pool.
at line 205
PoolOptionInterface
getOption()
Get the pool configuration options.
at line 213
int
getConnectionsInChannel()
Get the number of connections currently available in the pool.
at line 221
protected void
initOption(array $options = [])
Initialize pool options from configuration.
at line 262
abstract protected ConnectionInterface
createConnection()
Create a new connection for the pool.
at line 267
protected ConnectionInterface|false
popIdleConnection()
Pop and validate one idle connection.
at line 291
protected void
requeueConnection(ConnectionInterface $connection)
Return an idle connection without changing its activity timestamps.
at line 309
protected void
destroyConnection(ConnectionInterface $connection)
Destroy a managed connection and release its capacity.
at line 333
protected void
report(Throwable|string $error)
Report a pool maintenance or cleanup failure without throwing.
at line 344
protected StdoutLoggerInterface|null
getLogger()
Get the logger instance if available.
at line 431
protected int
nanoseconds(float $seconds)
Convert seconds to nanoseconds without overflowing integer arithmetic.
at line 441
protected int
deadline(float $seconds)
Build a monotonic deadline without overflowing at long durations or uptimes.