改名
This commit is contained in:
@@ -10,6 +10,7 @@ use HttpServer\Http\Context;
|
|||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use PDO;
|
use PDO;
|
||||||
use Redis;
|
use Redis;
|
||||||
|
use Snowflake\Pool\Timeout;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\Coroutine\Channel;
|
use Swoole\Coroutine\Channel;
|
||||||
use Swoole\Timer;
|
use Swoole\Timer;
|
||||||
@@ -26,6 +27,8 @@ abstract class Pool extends Component
|
|||||||
|
|
||||||
protected int $max = 60;
|
protected int $max = 60;
|
||||||
|
|
||||||
|
use Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param false $isMaster
|
* @param false $isMaster
|
||||||
@@ -127,6 +130,10 @@ abstract class Pool extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->creates === 0) {
|
||||||
|
$this->creates = Timer::tick(1000, [$this, 'Heartbeat_detection']);
|
||||||
|
}
|
||||||
|
|
||||||
Context::setContext('create:connect:' . $coroutineName, 1);
|
Context::setContext('create:connect:' . $coroutineName, 1);
|
||||||
|
|
||||||
$this->push($coroutineName, call_user_func($createHandler, ...$config));
|
$this->push($coroutineName, call_user_func($createHandler, ...$config));
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ SCRIPT;
|
|||||||
* 销毁连接池
|
* 销毁连接池
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function destroy()
|
public function destroy()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ use Swoole\Timer;
|
|||||||
class Connection extends Pool
|
class Connection extends Pool
|
||||||
{
|
{
|
||||||
|
|
||||||
use Timeout;
|
|
||||||
|
|
||||||
public array $hasCreate = [];
|
public array $hasCreate = [];
|
||||||
|
|
||||||
@@ -179,9 +178,6 @@ class Connection extends Pool
|
|||||||
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
|
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
|
||||||
$number > 0 && $link->beginTransaction();
|
$number > 0 && $link->beginTransaction();
|
||||||
}
|
}
|
||||||
if ($this->creates === 0) {
|
|
||||||
$this->creates = Timer::tick(1000, [$this, 'Heartbeat_detection']);
|
|
||||||
}
|
|
||||||
return $link;
|
return $link;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ use Swoole\Timer;
|
|||||||
class Redis extends Pool
|
class Redis extends Pool
|
||||||
{
|
{
|
||||||
|
|
||||||
use Timeout;
|
|
||||||
|
|
||||||
|
|
||||||
private int $_create = 0;
|
private int $_create = 0;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use Swoole\Timer;
|
|||||||
trait Timeout
|
trait Timeout
|
||||||
{
|
{
|
||||||
|
|
||||||
private int $creates = 0;
|
private int $creates = -1;
|
||||||
|
|
||||||
|
|
||||||
private int $lastTime = 0;
|
private int $lastTime = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user