PooledConnection
class PooledConnection implements Connection
Wraps a database Connection for use with Hypervel's connection pool.
This adapter implements Hypervel's pool connection contract, allowing our Laravel-ported Connection to work with Hypervel's pooling infrastructure.
Constants
| protected MAX_ERROR_COUNT |
Maximum allowed errors before marking connection as stale. |
Properties
| protected Connection|null | $connection | ||
| protected ConnectionLease|null | $lease | ||
| protected bool | $driverConnectionConfigured | ||
| protected ConnectionFactory | $factory | ||
| protected LoggerInterface | $logger | ||
| protected float | $lastUseTime | ||
| protected float | $lastReleaseTime | ||
| protected float | $createdAt | ||
| protected float|null | $lifetimeExpiresAt | ||
| protected bool | $availableForReuse | ||
| protected bool | $invalid | ||
| protected bool | $connectionEstablishedEventPending |
Methods
Create a new pooled connection instance.
Get the underlying database connection.
Get the active connection, reconnecting if necessary.
Get the internal driver resource holder for the current generation.
Determine whether borrowers receive a caller-owned logical connection for this slot.
Create a caller-owned logical connection for this borrowed slot.
Attach a logical owner without retaining its state between borrowers.
Forget physical resources after their logical owner disconnected.
Reconnect to the database.
Configure services used by the caller-visible connection.
Notify listeners after the resolver has registered the connection.
Check if the connection is still valid.
Determine if this connection has been idle long enough to be evicted.
Ping the underlying database connection.
Close the database connection.
Close the internal resource holder without settling its borrowed slot.
Clean up the owning connection and notify listeners before detachment.
Record the physical holder's grammar format without borrowing a session.
Release the connection back to the pool.
Discard the connection from its pool.
Get the last use time.
Get the last release time.
Get the connection generation creation time.
Determine if this connection generation has reached its maximum lifetime.
Determine if the underlying connection has an open transaction.
Mark the connection as invalid.
Mark the connection as valid.
Create driver resources for a new physical connection generation.
Details
at line 65
__construct(Container $container, DatabasePool $pool, array $config)
Create a new pooled connection instance.
at line 79
mixed
getConnection()
Get the underlying database connection.
at line 87
Connection
getActiveConnection()
Get the active connection, reconnecting if necessary.
at line 109
Connection
getDriverConnection()
| internal |
Get the internal driver resource holder for the current generation.
at line 129
bool
usesSessionLeases()
| internal |
Determine whether borrowers receive a caller-owned logical connection for this slot.
at line 140
ConnectionLease
newLease()
| internal |
Create a caller-owned logical connection for this borrowed slot.
at line 153
void
attachLease(ConnectionLease $lease)
| internal |
Attach a logical owner without retaining its state between borrowers.
at line 165
protected void
forgetDriverConnection()
Forget physical resources after their logical owner disconnected.
at line 187
bool
reconnect()
Reconnect to the database.
at line 230
protected void
configureConnection(Connection $connection)
Configure services used by the caller-visible connection.
at line 246
void
dispatchConnectionEstablishedEvent()
| internal |
Notify listeners after the resolver has registered the connection.
at line 272
bool
check()
Check if the connection is still valid.
at line 304
bool
isIdleExpired(float|null $now = null)
Determine if this connection has been idle long enough to be evicted.
at line 318
bool
ping(float $timeout)
Ping the underlying database connection.
at line 351
bool
close()
Close the database connection.
at line 372
protected void
closeDriverConnection()
Close the internal resource holder without settling its borrowed slot.
at line 394
protected void
prepareForRelease()
Clean up the owning connection and notify listeners before detachment.
at line 442
void
recordDateFormat()
| internal |
Record the physical holder's grammar format without borrowing a session.
A fresh logical lease is built from the same factory configuration as the holder, so owner-specific grammar changes must not reach the pool. Without leases the holder is the caller-visible connection itself.
at line 452
void
release()
Release the connection back to the pool.
at line 528
void
discard()
Discard the connection from its pool.
at line 536
float
getLastUseTime()
Get the last use time.
at line 544
float
getLastReleaseTime()
Get the last release time.
at line 552
float
getCreatedAt()
Get the connection generation creation time.
at line 560
bool
isLifetimeExpired(float|null $now = null)
Determine if this connection generation has reached its maximum lifetime.
at line 572
bool
hasOpenTransaction()
Determine if the underlying connection has an open transaction.
at line 581
protected void
markInvalid()
Mark the connection as invalid.
at line 591
protected void
markValid()
Mark the connection as valid.
at line 608
protected Connection
makeConnection()
Create driver resources for a new physical connection generation.
at line 637
protected void
refresh(Connection $connection)
Refresh the database connection resources.