modify plugin name
This commit is contained in:
@@ -30,9 +30,8 @@ class Connection extends Component
|
|||||||
* db is in transaction
|
* db is in transaction
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function inTransaction($cds): bool
|
public function inTransaction($name): bool
|
||||||
{
|
{
|
||||||
$name = $this->name('Mysql:' . $cds, true);
|
|
||||||
$connection = Context::getContext($name);
|
$connection = Context::getContext($name);
|
||||||
if ($connection instanceof PDO) {
|
if ($connection instanceof PDO) {
|
||||||
return $connection->inTransaction();
|
return $connection->inTransaction();
|
||||||
@@ -46,7 +45,6 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function beginTransaction($coroutineName)
|
public function beginTransaction($coroutineName)
|
||||||
{
|
{
|
||||||
$coroutineName = $this->name('Mysql:' . $coroutineName, true);
|
|
||||||
$connection = Context::getContext($coroutineName);
|
$connection = Context::getContext($coroutineName);
|
||||||
if ($connection instanceof PDO) {
|
if ($connection instanceof PDO) {
|
||||||
$connection->beginTransaction();
|
$connection->beginTransaction();
|
||||||
@@ -59,7 +57,6 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function commit($coroutineName)
|
public function commit($coroutineName)
|
||||||
{
|
{
|
||||||
$coroutineName = $this->name('Mysql:' . $coroutineName, true);
|
|
||||||
$connection = Context::getContext($coroutineName);
|
$connection = Context::getContext($coroutineName);
|
||||||
if ($connection instanceof PDO) {
|
if ($connection instanceof PDO) {
|
||||||
$connection->commit();
|
$connection->commit();
|
||||||
@@ -73,7 +70,6 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function rollback($coroutineName)
|
public function rollback($coroutineName)
|
||||||
{
|
{
|
||||||
$coroutineName = $this->name('Mysql:' . $coroutineName, true);
|
|
||||||
$connection = Context::getContext($coroutineName);
|
$connection = Context::getContext($coroutineName);
|
||||||
if ($connection instanceof PDO) {
|
if ($connection instanceof PDO) {
|
||||||
$connection->rollBack();
|
$connection->rollBack();
|
||||||
@@ -83,16 +79,14 @@ class Connection extends Component
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $config
|
* @param mixed $config
|
||||||
* @param bool $isMaster
|
|
||||||
* @return PDO|null
|
* @return PDO|null
|
||||||
* @throws Exception
|
* @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 = Context::getContext($coroutineName)) instanceof PDO) {
|
||||||
if ($connection instanceof PDO) {
|
|
||||||
return $connection;
|
return $connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,27 +130,22 @@ class Connection extends Component
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param $isMaster
|
|
||||||
* @param $max
|
* @param $max
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function initConnections($name, $isMaster, $max)
|
public function initConnections($name, $max)
|
||||||
{
|
{
|
||||||
$pool = $this->getPool();
|
$this->getPool()->initConnections($name, $max);
|
||||||
$pool->initConnections($name, $isMaster, $max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $coroutineName
|
* @param $coroutineName
|
||||||
* @param $isMaster
|
|
||||||
* @throws Kiri\Exception\ConfigException
|
* @throws Kiri\Exception\ConfigException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function release($coroutineName, $isMaster)
|
public function release($coroutineName)
|
||||||
{
|
{
|
||||||
$coroutineName = $this->name('Mysql:' . $coroutineName, $isMaster);
|
|
||||||
|
|
||||||
$client = Context::getContext($coroutineName);
|
$client = Context::getContext($coroutineName);
|
||||||
if (!($client instanceof PDO) || $client->inTransaction()) {
|
if (!($client instanceof PDO) || $client->inTransaction()) {
|
||||||
return;
|
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
|
* @param $coroutineName
|
||||||
@@ -196,9 +171,9 @@ class Connection extends Component
|
|||||||
* batch release
|
* batch release
|
||||||
* @throws Exception
|
* @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 $coroutineName
|
||||||
* @param bool $isMaster
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function disconnect($coroutineName, bool $isMaster = false)
|
public function disconnect($coroutineName)
|
||||||
{
|
{
|
||||||
Context::remove($coroutineName);
|
Context::remove($coroutineName);
|
||||||
$coroutineName = $this->name('Mysql:' . $coroutineName, $isMaster);
|
|
||||||
$this->getPool()->clean($coroutineName);
|
$this->getPool()->clean($coroutineName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,13 +59,11 @@ class Pool extends Component
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param false $isMaster
|
|
||||||
* @param int $max
|
* @param int $max
|
||||||
* @throws ConfigException
|
* @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])) {
|
if (isset(static::$_connections[$name])) {
|
||||||
$value = static::$_connections[$name];
|
$value = static::$_connections[$name];
|
||||||
if ($value instanceof Channel || $value instanceof SplQueue) {
|
if ($value instanceof Channel || $value instanceof SplQueue) {
|
||||||
|
|||||||
Reference in New Issue
Block a user