KeepaliveConnection
abstract class KeepaliveConnection implements ConnectionInterface
Abstract connection that maintains a keepalive heartbeat.
Uses a timer to periodically check connection health and automatically closes idle connections.
Properties
| protected Timer | $timer | ||
| protected Channel | $channel | ||
| protected float | $lastUseTime | ||
| protected int|null | $timerId | ||
| protected bool | $connected | ||
| protected string | $name |
Methods
Release the connection back to the pool.
Discard the connection from its pool.
No description
Check if the connection is valid.
Reconnect to the server.
Check if currently connected.
Close the connection.
Check if the connection has timed out.
Add a heartbeat timer when heartbeat is enabled.
Clear the connection state.
Get the logger instance.
Send a heartbeat to keep the connection alive.
Send a close protocol message.
Connect and return the active connection.
Details
at line 48
void
release()
Release the connection back to the pool.
at line 56
void
discard()
Discard the connection from its pool.
at line 64
mixed
getConnection()
No description
at line 72
bool
check()
Check if the connection is valid.
at line 80
bool
reconnect()
Reconnect to the server.
at line 107
mixed
call(Closure $closure, bool $refresh = true)
Execute a closure with the connection.
at line 138
bool
isConnected()
Check if currently connected.
at line 146
bool
close()
Close the connection.
at line 166
bool
isTimeout()
Check if the connection has timed out.
at line 178
protected void
addHeartbeat()
Add a heartbeat timer when heartbeat is enabled.
For keepalive connections, max_idle_time eviction is driven by this timer, so disabling heartbeat also disables background idle closing.
at line 218
protected void
clear()
Clear the connection state.
at line 245
protected LoggerInterface|null
getLogger()
Get the logger instance.
at line 257
protected void
heartbeat()
Send a heartbeat to keep the connection alive.
at line 264
protected void
sendClose(mixed $connection)
Send a close protocol message.
at line 271
abstract protected mixed
getActiveConnection()
Connect and return the active connection.