This commit is contained in:
2021-01-05 18:30:58 +08:00
parent f1fd58f794
commit 6d3de65dbb
2 changed files with 27 additions and 2 deletions
+14 -1
View File
@@ -226,6 +226,7 @@ class Connection extends Pool
*/
private function newClient($config, $coroutineName): PDO|null
{
$this->printClients($config['cds'], $coroutineName, true);
return $this->createConnect($this->parseConfig($config, $coroutineName), $coroutineName, function ($cds, $username, $password, $charset, $coroutineName) {
$link = new PDO($cds, $username, $password, [
PDO::ATTR_EMULATE_PREPARES => false,
@@ -238,7 +239,7 @@ class Connection extends Pool
if (!empty($charset)) {
$link->query('SET NAMES ' . $charset);
}
$this->success('create client[address: ' . $cds . ', coroutine: ' . Coroutine::getCid() . ', has num: ' . $this->size($coroutineName) . ', has create: ' . $this->hasCreate[$coroutineName] . ']');
$this->printClients($cds, $coroutineName);
$this->incr($coroutineName);
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
$number > 0 && $link->beginTransaction();
@@ -253,6 +254,7 @@ class Connection extends Pool
/**
* @param $config
* @param $name
* @return array
*/
private function parseConfig($config, $name): array
@@ -261,6 +263,17 @@ class Connection extends Pool
}
/**
* @param $cds
* @param $coroutineName
* @param false $isBefore
*/
public function printClients($cds, $coroutineName, $isBefore = false)
{
$this->success(($isBefore ? 'before ' : '') . 'create client[address: ' . $cds . ', coroutine: ' . Coroutine::getCid() . ', has num: ' . $this->size($coroutineName) . ', has create: ' . $this->hasCreate[$coroutineName] . ']');
}
/**
* @param $coroutineName
* @param $isMaster