改名
This commit is contained in:
@@ -152,11 +152,11 @@ class Connection extends Pool
|
|||||||
[$coroutineId, $coroutineName] = $this->getIndex($config['cds'], $isMaster);
|
[$coroutineId, $coroutineName] = $this->getIndex($config['cds'], $isMaster);
|
||||||
if (Context::hasContext($coroutineName)) {
|
if (Context::hasContext($coroutineName)) {
|
||||||
return Context::getContext($coroutineName);
|
return Context::getContext($coroutineName);
|
||||||
} else if ($this->size($coroutineName) < 1) {
|
|
||||||
return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config));
|
|
||||||
} else {
|
|
||||||
return $this->getByChannel($coroutineName, $config);
|
|
||||||
}
|
}
|
||||||
|
if ($this->size($coroutineName) < 1) {
|
||||||
|
return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config));
|
||||||
|
}
|
||||||
|
return $this->getByChannel($coroutineName, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -186,23 +186,14 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
public function getByChannel($coroutineName, $config)
|
public function getByChannel($coroutineName, $config)
|
||||||
{
|
{
|
||||||
$this->info('client has :' . $this->size($coroutineName));
|
|
||||||
[$time, $client] = $this->get($coroutineName, -1);
|
[$time, $client] = $this->get($coroutineName, -1);
|
||||||
|
|
||||||
$this->info('client has create :' . ($this->hasCreate[$coroutineName] ?? 0) . ':' . $this->max);
|
$this->info('client has create :' . ($this->hasCreate[$coroutineName] ?? 0) . ':' . $this->max);
|
||||||
if ($client instanceof PDO) {
|
if ($client instanceof PDO) {
|
||||||
return $this->saveClient($coroutineName, $client);
|
return $this->saveClient($coroutineName, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($client);
|
unset($client);
|
||||||
if (($this->hasCreate[$coroutineName] ?? 0) >= $this->max) {
|
if ($this->hasCreate[$coroutineName] > $this->max) {
|
||||||
[$time, $client] = $this->get($coroutineName, -1);
|
return $this->get($coroutineName)[1];
|
||||||
|
|
||||||
return $client;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->size($coroutineName) < 1) {
|
|
||||||
return $this->saveClient($coroutineName, $this->nowClient($coroutineName, $config));
|
|
||||||
}
|
}
|
||||||
return $this->getByChannel($coroutineName, $config);
|
return $this->getByChannel($coroutineName, $config);
|
||||||
}
|
}
|
||||||
@@ -227,11 +218,8 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
private function nowClient($coroutineName, $config)
|
private function nowClient($coroutineName, $config)
|
||||||
{
|
{
|
||||||
if ($this->size($coroutineName) > 0) {
|
|
||||||
return $this->getByChannel($coroutineName, $config);
|
|
||||||
}
|
|
||||||
$client = $this->createConnect($config['cds'], $config['username'], $config['password']);
|
|
||||||
$this->success('create db client -> ' . $config['cds'] . ':' . $this->size($coroutineName));
|
$this->success('create db client -> ' . $config['cds'] . ':' . $this->size($coroutineName));
|
||||||
|
$client = $this->createConnect($config['cds'], $config['username'], $config['password']);
|
||||||
if (isset(Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()])) {
|
if (isset(Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()])) {
|
||||||
$number = Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()];
|
$number = Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()];
|
||||||
$number > 0 && $client->beginTransaction();
|
$number > 0 && $client->beginTransaction();
|
||||||
|
|||||||
Reference in New Issue
Block a user