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 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.

bool
reconnect()

Reconnect to the database.

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
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.

void
refresh(Connection $connection)

Refresh the database connection resources.

Details

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

Create a new pooled connection instance.

Parameters

Container $container
DatabasePool $pool
array $config

at line 75
mixed getConnection()

Get the underlying database connection.

Return Value

mixed

at line 83
Connection getActiveConnection()

Get the active connection, reconnecting if necessary.

Return Value

Connection

at line 101
bool reconnect()

Reconnect to the database.

Return Value

bool

at line 161
void dispatchConnectionEstablishedEvent()

internal  
 

Notify listeners after the resolver has registered the connection.

Return Value

void

at line 184
bool check()

Check if the connection is still valid.

Return Value

bool

at line 216
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 230
bool ping(float $timeout)

Ping the underlying database connection.

Parameters

float $timeout

Return Value

bool

at line 304
bool close()

Close the database connection.

Return Value

bool

at line 324
void release()

Release the connection back to the pool.

Return Value

void

at line 415
void discard()

Discard the connection from its pool.

Return Value

void

at line 423
float getLastUseTime()

Get the last use time.

Return Value

float

at line 431
float getLastReleaseTime()

Get the last release time.

Return Value

float

at line 439
float getCreatedAt()

Get the connection generation creation time.

Return Value

float

at line 447
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 459
bool hasOpenTransaction()

Determine if the underlying connection has an open transaction.

Return Value

bool

at line 468
protected void markInvalid()

Mark the connection as invalid.

Return Value

void

at line 476
protected void markValid()

Mark the connection as valid.

Return Value

void

at line 493
protected void refresh(Connection $connection)

Refresh the database connection resources.

Parameters

Connection $connection

Return Value

void