This commit is contained in:
as2252258@163.com
2021-07-11 04:20:28 +08:00
parent a142c1e951
commit f1baed32b6
+6 -3
View File
@@ -24,6 +24,8 @@ use Snowflake\Abstracts\Config;
class DatabasesProviders extends Providers
{
private array $_pooLength = ['min' => 0, 'max' => 1];
/**
* @param Application $application
@@ -33,6 +35,8 @@ class DatabasesProviders extends Providers
{
$application->set('db', $this);
$this->_pooLength = Config::get('databases.pool', ['min' => 0, 'max' => 1]);
Event::on(Event::SERVER_TASK_START, [$this, 'createPool']);
Event::on(Event::SERVER_WORKER_START, [$this, 'createPool']);
}
@@ -80,7 +84,6 @@ class DatabasesProviders extends Providers
*/
private function _settings($database)
{
$max = Config::get('databases.pool', [0, 10]);
return [
'class' => Connection::class,
'id' => $database['id'],
@@ -89,8 +92,8 @@ class DatabasesProviders extends Providers
'password' => $database['password'],
'tablePrefix' => $database['tablePrefix'],
'database' => $database['database'],
'maxNumber' => $max['max'],
'minNumber' => $max['min'],
'maxNumber' => $this->_pooLength['max'],
'minNumber' => $this->_pooLength['min'],
'charset' => $database['charset'] ?? 'utf8mb4',
'slaveConfig' => $database['slaveConfig']
];