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

__construct(Container $container, DatabasePool $pool, array $config)

Create a new pooled connection instance.

mixed
getConnection()

Get the underlying database connection.

getActiveConnection()

Get the active connection, reconnecting if necessary.

getDriverConnection()

Get the internal driver resource holder for the current generation.

bool
usesSessionLeases()

Determine whether borrowers receive a caller-owned logical connection for this slot.

newLease()

Create a caller-owned logical connection for this borrowed slot.

void
attachLease(ConnectionLease $lease)

Attach a logical owner without retaining its state between borrowers.

void
forgetDriverConnection()

Forget physical resources after their logical owner disconnected.

bool
reconnect()

Reconnect to the database.

void
configureConnection(Connection $connection)

Configure services used by the caller-visible connection.

void
dispatchConnectionEstablishedEvent()

Notify listeners after the resolver has registered the connection.

bool
check()

Check if the connection is still valid.

bool
isIdleExpired(float|null $now = null)

Determine if this connection has been idle long enough to be evicted.

bool
ping(float $timeout)

Ping the underlying database connection.

bool
close()

Close the database connection.

void
closeDriverConnection()

Close the internal resource holder without settling its borrowed slot.

void
prepareForRelease()

Clean up the owning connection and notify listeners before detachment.

void
recordDateFormat()

Record the physical holder's grammar format without borrowing a session.

void
release()

Release the connection back to the pool.

void
discard()

Discard the connection from its pool.

float
getLastUseTime()

Get the last use time.

float
getLastReleaseTime()

Get the last release time.

float
getCreatedAt()

Get the connection generation creation time.

bool
isLifetimeExpired(float|null $now = null)

Determine if this connection generation has reached its maximum lifetime.

bool
hasOpenTransaction()

Determine if the underlying connection has an open transaction.

void
markInvalid()

Mark the connection as invalid.

void
markValid()

Mark the connection as valid.

makeConnection()

Create driver resources for a new physical connection generation.

void
refresh(Connection $connection)

Refresh the database connection resources.

Details

at line 65
__construct(Container $container, DatabasePool $pool, array $config)

Create a new pooled connection instance.

Parameters

Container $container
DatabasePool $pool
array $config

at line 79
mixed getConnection()

Get the underlying database connection.

Return Value

mixed

at line 87
Connection getActiveConnection()

Get the active connection, reconnecting if necessary.

Return Value

Connection

at line 109
Connection getDriverConnection()

internal  
 

Get the internal driver resource holder for the current generation.

Return Value

Connection

at line 129
bool usesSessionLeases()

internal  
 

Determine whether borrowers receive a caller-owned logical connection for this slot.

Return Value

bool

at line 140
ConnectionLease newLease()

internal  
 

Create a caller-owned logical connection for this borrowed slot.

Return Value

ConnectionLease

at line 153
void attachLease(ConnectionLease $lease)

internal  
 

Attach a logical owner without retaining its state between borrowers.

Parameters

ConnectionLease $lease

Return Value

void

at line 165
protected void forgetDriverConnection()

Forget physical resources after their logical owner disconnected.

Return Value

void

at line 187
bool reconnect()

Reconnect to the database.

Return Value

bool

at line 230
protected void configureConnection(Connection $connection)

Configure services used by the caller-visible connection.

Parameters

Connection $connection

Return Value

void

at line 246
void dispatchConnectionEstablishedEvent()

internal  
 

Notify listeners after the resolver has registered the connection.

Return Value

void

at line 272
bool check()

Check if the connection is still valid.

Return Value

bool

at line 304
bool isIdleExpired(float|null $now = null)

Determine if this connection has been idle long enough to be evicted.

Parameters

float|null $now

Return Value

bool

at line 318
bool ping(float $timeout)

Ping the underlying database connection.

Parameters

float $timeout

Return Value

bool

at line 351
bool close()

Close the database connection.

Return Value

bool

at line 372
protected void closeDriverConnection()

Close the internal resource holder without settling its borrowed slot.

Return Value

void

at line 394
protected void prepareForRelease()

Clean up the owning connection and notify listeners before detachment.

Return Value

void

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.

Return Value

void

at line 452
void release()

Release the connection back to the pool.

Return Value

void

at line 528
void discard()

Discard the connection from its pool.

Return Value

void

at line 536
float getLastUseTime()

Get the last use time.

Return Value

float

at line 544
float getLastReleaseTime()

Get the last release time.

Return Value

float

at line 552
float getCreatedAt()

Get the connection generation creation time.

Return Value

float

at line 560
bool isLifetimeExpired(float|null $now = null)

Determine if this connection generation has reached its maximum lifetime.

Parameters

float|null $now

Return Value

bool

at line 572
bool hasOpenTransaction()

Determine if the underlying connection has an open transaction.

Return Value

bool

at line 581
protected void markInvalid()

Mark the connection as invalid.

Return Value

void

at line 591
protected void markValid()

Mark the connection as valid.

Return Value

void

at line 608
protected Connection makeConnection()

Create driver resources for a new physical connection generation.

Return Value

Connection

at line 637
protected void refresh(Connection $connection)

Refresh the database connection resources.

Parameters

Connection $connection

Return Value

void