diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 5b4513b4..6a7d27a3 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -235,7 +235,6 @@ class Connection extends Pool */ private function nowClient($coroutineName, $config) { - $this->success('create db client -> ' . $config['cds'] . ':' . $this->hasCreate[$coroutineName] . ':' . $this->size($coroutineName)); $client = $this->createConnect($coroutineName, ...$this->parseConfig($config)); if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) { $number > 0 && $client->beginTransaction(); @@ -372,6 +371,7 @@ class Connection extends Pool if (!empty($charset)) { $link->query('SET NAMES ' . $charset); } + $this->success('create db client -> ' . $cds . ':' . $this->hasCreate[$coroutineName] . ':' . $this->size($coroutineName)); $this->incr($coroutineName); return $link; } catch (\Throwable $exception) { diff --git a/System/Pool/Redis.php b/System/Pool/Redis.php index 72dec475..473e8730 100644 --- a/System/Pool/Redis.php +++ b/System/Pool/Redis.php @@ -40,8 +40,7 @@ class Redis extends Pool if (Context::hasContext($coroutineName)) { return Context::getContext($coroutineName); } else if (!$this->hasItem($coroutineName)) { - $this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName)); - return $this->saveClient($coroutineName, $this->createConnect($config)); + return $this->saveClient($coroutineName, $this->createConnect($config, $coroutineName)); } return $this->getByChannel($coroutineName, $config); } @@ -56,8 +55,7 @@ class Redis extends Pool public function getByChannel($coroutineName, $config) { if (!$this->hasItem($coroutineName)) { - $this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName)); - return $this->saveClient($coroutineName, $this->createConnect($config)); + return $this->saveClient($coroutineName, $this->createConnect($config, $coroutineName)); } $clients = $this->get($coroutineName); if ($clients[1] === null) { @@ -81,10 +79,11 @@ class Redis extends Pool /** * @param array $config + * @param string $coroutineName * @return SRedis - * @throws Exception + * @throws RedisConnectException */ - private function createConnect(array $config) + private function createConnect(array $config, string $coroutineName) { $redis = new SRedis(); if (!$redis->connect($config['host'], $config['port'], $config['timeout'])) { @@ -93,6 +92,7 @@ class Redis extends Pool if (empty($config['auth']) || !$redis->auth($config['auth'])) { throw new RedisConnectException(sprintf('Redis Error: %s, Host %s, Auth %s', $redis->getLastError(), $config['host'], $config['auth'])); } + $this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName)); if (!isset($config['read_timeout'])) { $config['read_timeout'] = 10; }