1
0
Fork 0
mirror of synced 2024-07-04 14:10:33 +12:00

Renamed DatabasePool to Pools

This commit is contained in:
Eldad Fux 2022-10-08 08:43:02 +03:00
parent 5af7dc943f
commit 26b1a94d22
3 changed files with 17 additions and 24 deletions

View file

@ -2,7 +2,6 @@
require_once __DIR__ . '/../vendor/autoload.php';
use Appwrite\Database\DatabasePool;
use Appwrite\Utopia\Response;
use Swoole\Process;
use Swoole\Http\Server;

View file

@ -49,7 +49,7 @@ use MaxMind\Db\Reader;
use PHPMailer\PHPMailer\PHPMailer;
use Utopia\Database\Document;
use Utopia\Database\Database;
use Appwrite\Database\DatabasePool;
use Appwrite\Database\Pools;
use Appwrite\Event\Delete;
use Utopia\Database\Validator\Structure;
use Utopia\Database\Validator\Authorization;
@ -475,7 +475,7 @@ $register->set('dbPool', function () {
$projectDBs[$name] = $dsn;
}
$pool = new DatabasePool($consoleDBs, $projectDBs);
$pool = new Pools($consoleDBs, $projectDBs);
return $pool;
});

View file

@ -2,22 +2,16 @@
namespace Appwrite\Database;
use Appwrite\Database\PDO as DatabasePDO;
use PDO;
use Utopia\App;
use Appwrite\DSN\DSN;
use Utopia\CLI\Console;
use Utopia\Cache\Cache;
use Swoole\Database\PDOProxy;
use Utopia\Database\Database;
use Appwrite\Extend\Exception;
use Appwrite\Database\PDOPool;
use Swoole\Database\PDOConfig;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Validator\Authorization;
use Utopia\Cache\Adapter\Redis as RedisCache;
class DatabasePool
class Pools
{
/**
* @var array
@ -64,20 +58,20 @@ class DatabasePool
foreach ($this->dsns as $name => $dsn) {
$dsn = new DSN($dsn);
$pdoConfig = (new PDOConfig())
->withHost($dsn->getHost())
->withPort($dsn->getPort())
->withDbName($dsn->getDatabase())
->withCharset('utf8mb4')
->withUsername($dsn->getUser())
->withPassword($dsn->getPassword())
->withOptions([
PDO::ATTR_ERRMODE => App::isDevelopment() ? PDO::ERRMODE_WARNING : PDO::ERRMODE_SILENT, // If in production mode, warnings are not displayed
PDO::ATTR_TIMEOUT => 3, // Seconds
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => true,
PDO::ATTR_STRINGIFY_FETCHES => true
]);
->withHost($dsn->getHost())
->withPort($dsn->getPort())
->withDbName($dsn->getDatabase())
->withCharset('utf8mb4')
->withUsername($dsn->getUser())
->withPassword($dsn->getPassword())
->withOptions([
PDO::ATTR_ERRMODE => App::isDevelopment() ? PDO::ERRMODE_WARNING : PDO::ERRMODE_SILENT, // If in production mode, warnings are not displayed
PDO::ATTR_TIMEOUT => 3, // Seconds
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => true,
PDO::ATTR_STRINGIFY_FETCHES => true
]);
$pool = new PDOPool($pdoConfig, $name, 64);