变更
This commit is contained in:
@@ -25,6 +25,8 @@ class Connection extends Component
|
|||||||
|
|
||||||
private array $master = [];
|
private array $master = [];
|
||||||
|
|
||||||
|
private int $total = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Pool $pool
|
* @param Pool $pool
|
||||||
@@ -150,7 +152,11 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function create($config): Closure
|
public function create($config): Closure
|
||||||
{
|
{
|
||||||
return static function () use ($config) {
|
return function () use ($config) {
|
||||||
|
if ($this->total >= 300) {
|
||||||
|
return $this->pool->waite($config['cds'], 30);
|
||||||
|
}
|
||||||
|
$this->total += 1;
|
||||||
return new \Database\Mysql\PDO($config);
|
return new \Database\Mysql\PDO($config);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,19 @@ class Pool extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param int $time
|
||||||
|
* @return array
|
||||||
|
* @throws ConfigException
|
||||||
|
*/
|
||||||
|
public function waite($name, int $time = 30): mixed
|
||||||
|
{
|
||||||
|
return $this->channel($name)->pop($time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|||||||
Reference in New Issue
Block a user