改名
This commit is contained in:
+28
-19
@@ -80,29 +80,38 @@ class ClientsPool extends Component
|
|||||||
Timer::clear($this->creates);
|
Timer::clear($this->creates);
|
||||||
$this->creates = -1;
|
$this->creates = -1;
|
||||||
} else {
|
} else {
|
||||||
$min = Config::get('databases.pool.min', 1);
|
$this->heartbeat_flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$num = [];
|
|
||||||
$total = 0;
|
|
||||||
foreach (static::$_connections as $key => $channel) {
|
|
||||||
if (!isset($num[$key])) {
|
|
||||||
$num[$key] = 0;
|
|
||||||
}
|
|
||||||
if ($channel->length() > $min) {
|
|
||||||
$this->flush($channel, $min);
|
|
||||||
}
|
|
||||||
$length = $channel->length();
|
|
||||||
|
|
||||||
$num[$key] += $length;
|
/**
|
||||||
if (str_starts_with($key, 'Mysql') && (Snowflake::isWorker() || Snowflake::isTask()) && $length > 0) {
|
* @throws ConfigException
|
||||||
$this->debug('Worker #' . env('worker') . ' use client -> ' . $key . ':' . $length);
|
* @throws Exception
|
||||||
}
|
*/
|
||||||
$total += $length;
|
private function heartbeat_flush()
|
||||||
|
{
|
||||||
|
$min = Config::get('databases.pool.min', 1);
|
||||||
|
|
||||||
|
$num = [];
|
||||||
|
$total = 0;
|
||||||
|
foreach (static::$_connections as $key => $channel) {
|
||||||
|
if (!isset($num[$key])) {
|
||||||
|
$num[$key] = 0;
|
||||||
}
|
}
|
||||||
if ($total < 1) {
|
$length = $channel->length();
|
||||||
Timer::clear($this->creates);
|
if ($length > $min) {
|
||||||
$this->creates = -1;
|
$this->flush($channel, $min);
|
||||||
}
|
}
|
||||||
|
$num[$key] += $length;
|
||||||
|
if (str_starts_with($key, 'Mysql') && (Snowflake::isWorker() || Snowflake::isTask()) && $length > 0) {
|
||||||
|
$this->debug('Worker #' . env('worker') . ' use client -> ' . $key . ':' . $length);
|
||||||
|
}
|
||||||
|
$total += $length;
|
||||||
|
}
|
||||||
|
if ($total < 1) {
|
||||||
|
Timer::clear($this->creates);
|
||||||
|
$this->creates = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user