qqq
This commit is contained in:
+23
-6
@@ -150,14 +150,9 @@ class Connection extends Component
|
|||||||
{
|
{
|
||||||
/** @var PDO $client */
|
/** @var PDO $client */
|
||||||
$client = $this->pool()->get($this->cds);
|
$client = $this->pool()->get($this->cds);
|
||||||
try {
|
if ($this->canUse($client)) {
|
||||||
if (($steam = $client->query('select 1')) !== false) {
|
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
$this->logger->error($steam->errorInfo()[1]);
|
|
||||||
} catch (\Throwable $exception) {
|
|
||||||
$this->logger->error($exception);
|
|
||||||
}
|
|
||||||
Waite::sleep(10);
|
Waite::sleep(10);
|
||||||
return $this->checkClientHealth();
|
return $this->checkClientHealth();
|
||||||
}
|
}
|
||||||
@@ -181,6 +176,28 @@ class Connection extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PDO|null $client
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function canUse(?PDO $client): bool
|
||||||
|
{
|
||||||
|
if (is_null($client)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$steam = $client->query('select 1');
|
||||||
|
if ($steam !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (\Throwable $exception) {
|
||||||
|
$this->logger->error($exception);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PDO
|
* @return PDO
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|||||||
Reference in New Issue
Block a user