AsyncMysqlConnectResult::clientStats
Returns the MySQL client statistics at the moment the connection was established
public function clientStats(): AsyncMysqlClientStats;
This information can be used to know how the performance of the MySQL client may have affected the connecting operation.
Returns
AsyncMysqlClientStats
- anAsyncMysqlClientStats
object to query about event and callback timing to the MySQL client for the connection.
Examples
Every connection has a connection result. You get the connection result from a call to AsyncMysqlConnection::connectResult
. And one of the methods on an AsyncMysqlConnectResult
is clientStats()
, which gives you some information about the client you are connecting too.
require __DIR__.'/../../__includes/async_mysql_connect.inc.php';
use \Hack\UserDocumentation\API\Examples\AsyncMysql\ConnectionInfo as CI;
async function connect(
\AsyncMysqlConnectionPool $pool,
): Awaitable<\AsyncMysqlConnection> {
return await $pool->connect(
CI::$host,
CI::$port,
CI::$db,
CI::$user,
CI::$passwd,
);
}
async function get_client_stats(): Awaitable<?\AsyncMysqlClientStats> {
$pool = new \AsyncMysqlConnectionPool(darray[]);
$conn = await connect($pool);
$cstats = $conn->connectResult()?->clientStats();
\var_dump($cstats?->callbackDelayMicrosAvg());
$conn->close();
return $cstats;
}
function run(): void {
$cs = \HH\Asio\join(get_client_stats());
\var_dump($cs);
}
run();
float(42.44140625)
object(AsyncMysqlClientStats)#8 (0) {
}