From 70364d7a07450ba3fad11d839deeee01ac207a47 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 17 Apr 2025 17:09:08 +1200 Subject: [PATCH] Format --- app/cli.php | 2 +- app/controllers/api/health.php | 2 +- app/controllers/api/projects.php | 1 - app/http.php | 2 +- app/worker.php | 3 +- src/Appwrite/Messaging/Adapter/Realtime.php | 5 ++- .../Platform/Tasks/ScheduleExecutions.php | 4 +- .../Platform/Tasks/ScheduleFunctions.php | 42 +++++++++---------- .../Platform/Tasks/ScheduleMessages.php | 2 +- 9 files changed, 31 insertions(+), 32 deletions(-) diff --git a/app/cli.php b/app/cli.php index 44fb72f7ca..1a370ff10a 100644 --- a/app/cli.php +++ b/app/cli.php @@ -10,8 +10,8 @@ use Appwrite\Event\StatsUsage; use Appwrite\Platform\Appwrite; use Appwrite\Runtimes\Runtimes; use Executor\Executor; -use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Adapter\Pool as CachePool; +use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\CLI; use Utopia\CLI\Console; diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 1ab123ec29..b038806013 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -10,8 +10,8 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; use Utopia\App; -use Utopia\Config\Config; use Utopia\Cache\Adapter as CacheAdapter; +use Utopia\Config\Config; use Utopia\Database\Adapter as DatabaseAdapter; use Utopia\Database\Document; use Utopia\Domains\Validator\PublicDomain; diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 82b07759df..75ee3edb5d 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -25,7 +25,6 @@ use Utopia\Audit\Audit; use Utopia\Cache\Cache; use Utopia\Config\Config; use Utopia\Database\Adapter; -use Utopia\Database\Adapter\Pool as DatabasePool; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; diff --git a/app/http.php b/app/http.php index d3fa2089cc..8ee65dccf6 100644 --- a/app/http.php +++ b/app/http.php @@ -15,10 +15,10 @@ use Utopia\Audit\Audit; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Adapter\Pool as DatabasePool; -use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; +use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/app/worker.php b/app/worker.php index 7b70cba736..72ad5f3338 100644 --- a/app/worker.php +++ b/app/worker.php @@ -35,7 +35,6 @@ use Utopia\Logger\Log; use Utopia\Logger\Logger; use Utopia\Platform\Service; use Utopia\Pools\Group; -use Utopia\Queue\Consumer; use Utopia\Queue\Message; use Utopia\Queue\Publisher; use Utopia\Queue\Server; @@ -170,7 +169,7 @@ Server::setResource('getLogsDB', function (Group $pools, Cache $cache) { $database->setTenant($project->getInternalId()); return $database; } - + $adapter = new DatabasePool($pools->get('logs')); $database = new Database($adapter, $cache); diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index 87cad2f681..1454f03f93 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -2,8 +2,8 @@ namespace Appwrite\Messaging\Adapter; -use Appwrite\PubSub\Adapter as PubSubAdapter; use Appwrite\Messaging\Adapter as MessagingAdapter; +use Appwrite\PubSub\Adapter as PubSubAdapter; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; @@ -142,7 +142,8 @@ class Realtime extends MessagingAdapter global $register; - $register->get('pools')->get('pubsub')->use(fn (PubSubAdapter $redis) => + $register->get('pools')->get('pubsub')->use( + fn (PubSubAdapter $redis) => $redis->publish('realtime', json_encode([ 'project' => $projectId, 'roles' => $roles, diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 3539efec58..f1a4c3ed79 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -60,7 +60,7 @@ class ScheduleExecutions extends ScheduleBase \go(function () use ($schedule, $delay, $data, $pools) { Co::sleep($delay); - $pools->get('publisher')->use(function(Publisher $publisher) use ($schedule, $data) { + $pools->get('publisher')->use(function (Publisher $publisher) use ($schedule, $data) { $queueForFunctions = new Func($publisher); $queueForFunctions->setType('schedule') @@ -84,6 +84,6 @@ class ScheduleExecutions extends ScheduleBase ); unset($this->schedules[$schedule['$internalId']]); -} + } } } diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index f506cd3fd9..328c9f894c 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -75,28 +75,28 @@ class ScheduleFunctions extends ScheduleBase \sleep($delay); // in seconds - foreach ($scheduleKeys as $scheduleKey) { - // Ensure schedule was not deleted - if (!\array_key_exists($scheduleKey, $this->schedules)) { - return; - } - - $schedule = $this->schedules[$scheduleKey]; - - $this->updateProjectAccess($schedule['project'], $dbForPlatform); - - $pools->get('publisher')->use(function(Publisher $publisher) use ($schedule) { - $queueForFunctions = new Func($publisher); - - $queueForFunctions - ->setType('schedule') - ->setFunction($schedule['resource']) - ->setMethod('POST') - ->setPath('/') - ->setProject($schedule['project']) - ->trigger(); - }); + foreach ($scheduleKeys as $scheduleKey) { + // Ensure schedule was not deleted + if (!\array_key_exists($scheduleKey, $this->schedules)) { + return; } + + $schedule = $this->schedules[$scheduleKey]; + + $this->updateProjectAccess($schedule['project'], $dbForPlatform); + + $pools->get('publisher')->use(function (Publisher $publisher) use ($schedule) { + $queueForFunctions = new Func($publisher); + + $queueForFunctions + ->setType('schedule') + ->setFunction($schedule['resource']) + ->setMethod('POST') + ->setPath('/') + ->setProject($schedule['project']) + ->trigger(); + }); + } }); } diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 319e194b22..75b4a34b87 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -42,7 +42,7 @@ class ScheduleMessages extends ScheduleBase } \go(function () use ($schedule, $pools, $dbForPlatform) { - $pools->get('publisher')->use(function(Publisher $publisher) use ($schedule, $dbForPlatform) { + $pools->get('publisher')->use(function (Publisher $publisher) use ($schedule, $dbForPlatform) { $queueForMessaging = new Messaging($publisher); $this->updateProjectAccess($schedule['project'], $dbForPlatform);