From 698b0ad0ff86a8525cb07fb9118c2f58c3596525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 24 Feb 2022 11:00:01 +0800 Subject: [PATCH] modify plugin name --- kiri-engine/Pool/Connection.php | 47 +++++++-------------------------- kiri-engine/Pool/Pool.php | 4 +-- 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/kiri-engine/Pool/Connection.php b/kiri-engine/Pool/Connection.php index 41b7934d..b0bf87c7 100644 --- a/kiri-engine/Pool/Connection.php +++ b/kiri-engine/Pool/Connection.php @@ -30,9 +30,8 @@ class Connection extends Component * db is in transaction * @throws Exception */ - public function inTransaction($cds): bool + public function inTransaction($name): bool { - $name = $this->name('Mysql:' . $cds, true); $connection = Context::getContext($name); if ($connection instanceof PDO) { return $connection->inTransaction(); @@ -46,7 +45,6 @@ class Connection extends Component */ public function beginTransaction($coroutineName) { - $coroutineName = $this->name('Mysql:' . $coroutineName, true); $connection = Context::getContext($coroutineName); if ($connection instanceof PDO) { $connection->beginTransaction(); @@ -59,7 +57,6 @@ class Connection extends Component */ public function commit($coroutineName) { - $coroutineName = $this->name('Mysql:' . $coroutineName, true); $connection = Context::getContext($coroutineName); if ($connection instanceof PDO) { $connection->commit(); @@ -73,7 +70,6 @@ class Connection extends Component */ public function rollback($coroutineName) { - $coroutineName = $this->name('Mysql:' . $coroutineName, true); $connection = Context::getContext($coroutineName); if ($connection instanceof PDO) { $connection->rollBack(); @@ -83,16 +79,14 @@ class Connection extends Component /** * @param mixed $config - * @param bool $isMaster * @return PDO|null * @throws Exception */ - public function get(mixed $config, bool $isMaster = false): ?PDO + public function get(mixed $config): ?PDO { - $coroutineName = $this->name('Mysql:' . $config['cds'], $isMaster); + $coroutineName = $config['cds']; - $connection = Context::getContext($coroutineName); - if ($connection instanceof PDO) { + if (($connection = Context::getContext($coroutineName)) instanceof PDO) { return $connection; } @@ -136,27 +130,22 @@ class Connection extends Component /** * @param $name - * @param $isMaster * @param $max * @throws Exception */ - public function initConnections($name, $isMaster, $max) + public function initConnections($name, $max) { - $pool = $this->getPool(); - $pool->initConnections($name, $isMaster, $max); + $this->getPool()->initConnections($name, $max); } /** * @param $coroutineName - * @param $isMaster * @throws Kiri\Exception\ConfigException * @throws Exception */ - public function release($coroutineName, $isMaster) + public function release($coroutineName) { - $coroutineName = $this->name('Mysql:' . $coroutineName, $isMaster); - $client = Context::getContext($coroutineName); if (!($client instanceof PDO) || $client->inTransaction()) { return; @@ -167,20 +156,6 @@ class Connection extends Component } - /** - * @param $coroutineName - * @param PDO $PDO - * @param bool $isMaster - * @return void - * @throws Exception - * @throws Kiri\Exception\ConfigException - */ - public function recover($coroutineName, PDO $PDO, bool $isMaster = false) - { - $coroutineName = $this->name('Mysql:' . $coroutineName, $isMaster); - $this->getPool()->push($coroutineName, $PDO); - } - /** * @param $coroutineName @@ -196,9 +171,9 @@ class Connection extends Component * batch release * @throws Exception */ - public function connection_clear($name, $isMaster) + public function connection_clear($name) { - $this->getPool()->clean($this->name($name, $isMaster)); + $this->getPool()->clean($name); } @@ -226,13 +201,11 @@ class Connection extends Component /** * @param $coroutineName - * @param bool $isMaster * @throws Exception */ - public function disconnect($coroutineName, bool $isMaster = false) + public function disconnect($coroutineName) { Context::remove($coroutineName); - $coroutineName = $this->name('Mysql:' . $coroutineName, $isMaster); $this->getPool()->clean($coroutineName); } diff --git a/kiri-engine/Pool/Pool.php b/kiri-engine/Pool/Pool.php index ebbdfeae..30b0f654 100644 --- a/kiri-engine/Pool/Pool.php +++ b/kiri-engine/Pool/Pool.php @@ -59,13 +59,11 @@ class Pool extends Component /** * @param $name - * @param false $isMaster * @param int $max * @throws ConfigException */ - public function initConnections($name, bool $isMaster = false, int $max = 60) + public function initConnections($name, int $max = 60) { - $name = $this->name($name, $isMaster); if (isset(static::$_connections[$name])) { $value = static::$_connections[$name]; if ($value instanceof Channel || $value instanceof SplQueue) {