AsyncMysqlConnectResult::clientStats

Returns the MySQL client statistics at the moment the connection was established.

Description

public function clientStats(): AsyncMysqlClientStats

Returns the MySQL client statistics at the moment the connection was established.

This information can be used to know how the performance of the MySQL client may have affected the connecting operation.

Return Values

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.

<?hh

namespace Hack\UserDocumentation\API\Examples\AsyncMysql\ConnResult\ClientStats;

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(array());
  $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();
Output
float(42.44140625)
object(AsyncMysqlClientStats)#8 (0) {
}