From aff328c6604715ff409d67fcb87c481f5b399d2b Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 07:51:24 +0200 Subject: [PATCH] Fixed test --- app/controllers/api/health.php | 23 +++++++++++++++++------ app/worker.php | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index dd106f7d7b..391b286cca 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -6,6 +6,8 @@ use Appwrite\Extend\Exception; use Appwrite\Utopia\Queue\Connections; use Appwrite\Utopia\Response; use Utopia\Config\Config; +use Utopia\Database\Adapter\MariaDB; +use Utopia\Database\Adapter\MySQL; use Utopia\Database\Document; use Utopia\Domains\Validator\PublicDomain; use Utopia\Http\Http; @@ -72,21 +74,30 @@ Http::get('/v1/health/db') ->inject('response') ->inject('pools') ->inject('connections') - ->action(function (Response $response, Group $pools, Connections $connections) { + ->action(function (Response $response, array $pools, Connections $connections) { $output = []; $configs = [ - 'Console.DB' => Config::getParam('pools-console'), - 'Projects.DB' => Config::getParam('pools-database'), + 'console' => Config::getParam('pools-console'), + 'database' => Config::getParam('pools-database'), ]; foreach ($configs as $key => $config) { foreach ($config as $database) { try { - $connection = $pools->get($database)->pop(); - $connections->add($connection); - $adapter = $connection->getResource(); + + $pool = $pools['pools-'.$key.'-'.$database]['pool']; + $dsn = $pools['pools-'.$key.'-'.$database]['dsn']; + + $connection = $pool->get(); + $connections->add($connection, $pool); + $adapter = match ($dsn->getScheme()) { + 'mariadb' => new MariaDB($connection), + 'mysql' => new MySQL($connection), + default => null + }; + $adapter->setDatabase($dsn->getPath()); $checkStart = \microtime(true); diff --git a/app/worker.php b/app/worker.php index c8ba9e7741..9917164c20 100644 --- a/app/worker.php +++ b/app/worker.php @@ -178,6 +178,7 @@ $getProjectDB 'mysql' => new MySQL($connection), default => null }; + $adapter->setDatabase($dsn->getPath()); $database = new Database($adapter, $cache); $database->setAuthorization($auth);