From da5addf2f2bc672ce24922f7a1789c6368eaa81c Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 2 Nov 2022 16:43:42 +0200 Subject: [PATCH] addressing comments --- .env | 4 ++-- app/worker.php | 9 +++------ app/workers/sync-out.php | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.env b/.env index 900a443080..32c60b7935 100644 --- a/.env +++ b/.env @@ -84,8 +84,8 @@ _APP_MAINTENANCE_RETENTION_AUDIT=1209600 _APP_USAGE_TIMESERIES_INTERVAL=2 _APP_USAGE_DATABASE_INTERVAL=15 _APP_USAGE_STATS=enabled -_APP_LOGGING_PROVIDER=sentry -_APP_LOGGING_CONFIG=4190483bb7d14d659e526aa61b0c7b5e;4504077395230720 +_APP_LOGGING_PROVIDER= +_APP_LOGGING_CONFIG= _APP_REGION=nyc1 DOCKERHUB_PULL_USERNAME= DOCKERHUB_PULL_PASSWORD= diff --git a/app/worker.php b/app/worker.php index e1d46d4f46..f705636bf8 100644 --- a/app/worker.php +++ b/app/worker.php @@ -3,17 +3,14 @@ require_once __DIR__ . '/init.php'; use Appwrite\DSN\DSN; +use Appwrite\Extend\Exception; use Appwrite\URL\URL as AppwriteURL; use Swoole\Runtime; use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; -use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; -use Utopia\Database\Validator\Authorization; -use Utopia\Logger\Log; -use Utopia\Logger\Logger; use Utopia\Queue\Server; use Utopia\Registry\Registry; use Utopia\Queue; @@ -71,8 +68,8 @@ $fallbackForRedis = AppwriteURL::unparse([ $connection = App::getEnv('_APP_CONNECTIONS_QUEUE', $fallbackForRedis); $dsns = explode(',', $connection ?? ''); -if (empty($dsns[0])) { - Console::error("Dsn not found"); +if (empty($dsns)) { + throw new Exception(Exception::GENERAL_SERVER_ERROR); } $dsn = explode('=', $dsns[0]); diff --git a/app/workers/sync-out.php b/app/workers/sync-out.php index b8d55d212c..8c36cbe808 100644 --- a/app/workers/sync-out.php +++ b/app/workers/sync-out.php @@ -92,7 +92,7 @@ function handle($dbForConsole, $regions, $stack): void if ($response['status'] !== Response::STATUS_CODE_OK) { Console::error("[{$time}] Request to {$code} has failed"); - $dbForConsole->createDocument('syncs', new Document([ + $dbForConsole->createDocument('sync', new Document([ 'region' => App::getEnv('_APP_REGION'), 'target' => $code, 'keys' => $stack, @@ -103,8 +103,8 @@ function handle($dbForConsole, $regions, $stack): void } } -$adapter = new Queue\Adapter\Swoole($redisConnection, $workerNumber, 'syncOut'); -$server = new Queue\Server($adapter); +$adapter = new Queue\Adapter\Swoole($redisConnection, $workerNumber, 'syncOut'); +$server = new Queue\Server($adapter); $server->job() ->inject('message')