From 39aa1c2237bea57db0a67fdf0f8e364db96d0ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sat, 5 Sep 2020 01:49:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Abstracts/Pool.php | 7 +------ System/Pool/Connection.php | 39 +++----------------------------------- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index 8fbabad7..0965a7be 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -124,12 +124,7 @@ abstract class Pool extends Component */ public function push($name, $client) { - if (!isset($this->_items[$name])) { - return; - } - if (!$this->_items[$name]->isFull()) { - $this->_items[$name]->push([time(), $client]); - } + $this->_items[$name]->push([time(), $client]); } diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 1db0b4aa..760e8adb 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -158,42 +158,9 @@ class Connection extends Pool } if ($this->size($coroutineName) < 1 && $this->hasCreate[$coroutineName] < $this->max) { $this->info('client has create :' . ($this->hasCreate[$coroutineName] ?? 0) . ':' . $this->max); - return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config)); + $this->push($coroutineName, $this->nowClient($coroutineName, $config)); } - return $this->getByChannel($coroutineName, $config); - } - - - /** - * @param $name - * @param $config - * @return Connection - * @throws Exception - */ - public function fill($name, $config) - { - if ($this->size($name) >= 10) { - return $this; - } - for ($i = 0; $i < 10 - $this->size($name); $i++) { - $this->push($name, $this->createConnect($config['cds'], $config['username'], $config['password'])); - } - return $this; - } - - /** - * @param $coroutineName - * @param $config - * @return mixed - * @throws Exception - */ - public function getByChannel($coroutineName, $config) - { - [$time, $client] = $this->get($coroutineName); - if ($client instanceof PDO) { - return $this->saveClient($coroutineName, $client); - } - return $this->getByChannel($coroutineName, $config); + return $this->get($coroutineName)[1]; } @@ -343,7 +310,7 @@ class Connection extends Pool $this->addError($cds . ' -> ' . $exception->getMessage()); throw new Exception($exception->getMessage()); } - $this->addError($cds . ' -> ' . $exception->getMessage()); + $this->error($cds . ' -> ' . $exception->getMessage()); return $this->createConnect($coroutineName, $cds, $username, $password); } }