From b418285349bce3a6ff4f56b912aa8cb5bbc00fab Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Aug 2025 23:57:54 +1200 Subject: [PATCH] Revert "Merge pull request #10299 from appwrite/feat-functions-redis-queue" This reverts commit f81fd16d26c055a5c04fceb56ee9efb423470083, reversing changes made to ec174a15cf3ec73f6f265d0b08dedf51444241e0. --- app/cli.php | 3 --- app/controllers/api/health.php | 6 +++--- app/controllers/shared/api.php | 6 ++---- app/init/resources.php | 6 ------ app/worker.php | 8 -------- src/Appwrite/Platform/Tasks/ScheduleBase.php | 5 +---- src/Appwrite/Platform/Tasks/ScheduleExecutions.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 2 +- tests/e2e/Services/Messaging/MessagingBase.php | 2 -- 9 files changed, 8 insertions(+), 32 deletions(-) diff --git a/app/cli.php b/app/cli.php index 2ad37c0ce2..504e4fb5e6 100644 --- a/app/cli.php +++ b/app/cli.php @@ -194,9 +194,6 @@ CLI::setResource('publisher', function (Group $pools) { CLI::setResource('publisherDatabases', function (BrokerPool $publisher) { return $publisher; }, ['publisher']); -CLI::setResource('publisherFunctions', function (BrokerPool $publisher) { - return $publisher; -}, ['publisher']); CLI::setResource('publisherMigrations', function (BrokerPool $publisher) { return $publisher; }, ['publisher']); diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 32b77433f0..39ebae9590 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -686,12 +686,12 @@ App::get('/v1/health/queue/functions') contentType: ContentType::JSON )) ->param('threshold', 5000, new Integer(true), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.', true) - ->inject('publisherFunctions') + ->inject('publisher') ->inject('response') - ->action(function (int|string $threshold, Publisher $publisherFunctions, Response $response) { + ->action(function (int|string $threshold, Publisher $publisher, Response $response) { $threshold = \intval($threshold); - $size = $publisherFunctions->getQueueSize(new Queue(Event::FUNCTIONS_QUEUE_NAME)); + $size = $publisher->getQueueSize(new Queue(Event::FUNCTIONS_QUEUE_NAME)); if ($size >= $threshold) { throw new Exception(Exception::HEALTH_QUEUE_SIZE_EXCEEDED, "Queue size threshold hit. Current size is {$size} and threshold is {$threshold}."); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 1fed4362b5..c2f5c415a0 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -29,7 +29,6 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; -use Utopia\Queue\Broker\Pool as BrokerPool; use Utopia\Queue\Publisher; use Utopia\System\System; use Utopia\Telemetry\Adapter as Telemetry; @@ -409,7 +408,6 @@ App::init() ->inject('project') ->inject('user') ->inject('publisher') - ->inject('publisherFunctions') ->inject('queueForEvents') ->inject('queueForMessaging') ->inject('queueForAudits') @@ -425,7 +423,7 @@ App::init() ->inject('plan') ->inject('devKey') ->inject('telemetry') - ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Publisher $publisher, BrokerPool $publisherFunctions, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, StatsUsage $queueForStatsUsage, Database $dbForProject, callable $timelimit, Document $resourceToken, string $mode, ?Key $apiKey, array $plan, Document $devKey, Telemetry $telemetry) use ($usageDatabaseListener, $eventDatabaseListener) { + ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Publisher $publisher, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, StatsUsage $queueForStatsUsage, Database $dbForProject, callable $timelimit, Document $resourceToken, string $mode, ?Key $apiKey, array $plan, Document $devKey, Telemetry $telemetry) use ($usageDatabaseListener, $eventDatabaseListener) { $route = $utopia->getRoute(); @@ -537,7 +535,7 @@ App::init() // Clone the queues, to prevent events triggered by the database listener // from overwriting the events that are supposed to be triggered in the shutdown hook. $queueForEventsClone = new Event($publisher); - $queueForFunctions = new Func($publisherFunctions); + $queueForFunctions = new Func($publisher); $queueForWebhooks = new Webhook($publisher); $queueForRealtime = new Realtime(); diff --git a/app/init/resources.php b/app/init/resources.php index 8dcfc8ceb2..4d1e0444c5 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -83,9 +83,6 @@ App::setResource('publisher', function (Group $pools) { App::setResource('publisherDatabases', function (BrokerPool $publisher) { return $publisher; }, ['publisher']); -App::setResource('publisherFunctions', function (BrokerPool $publisher) { - return $publisher; -}, ['publisher']); App::setResource('publisherMigrations', function (BrokerPool $publisher) { return $publisher; }, ['publisher']); @@ -98,9 +95,6 @@ App::setResource('consumer', function (Group $pools) { App::setResource('consumerDatabases', function (BrokerPool $consumer) { return $consumer; }, ['consumer']); -App::setResource('consumerFunctions', function (BrokerPool $consumer) { - return $consumer; -}, ['consumer']); App::setResource('consumerMigrations', function (BrokerPool $consumer) { return $consumer; }, ['consumer']); diff --git a/app/worker.php b/app/worker.php index cc8aca2d8e..90f3368fe7 100644 --- a/app/worker.php +++ b/app/worker.php @@ -251,10 +251,6 @@ Server::setResource('publisherDatabases', function (BrokerPool $publisher) { return $publisher; }, ['publisher']); -Server::setResource('publisherFunctions', function (BrokerPool $publisher) { - return $publisher; -}, ['publisher']); - Server::setResource('publisherMigrations', function (BrokerPool $publisher) { return $publisher; }, ['publisher']); @@ -271,10 +267,6 @@ Server::setResource('consumerDatabases', function (BrokerPool $consumer) { return $consumer; }, ['consumer']); -Server::setResource('consumerFunctions', function (BrokerPool $consumer) { - return $consumer; -}, ['consumer']); - Server::setResource('consumerMigrations', function (BrokerPool $consumer) { return $consumer; }, ['consumer']); diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index 1710f0163d..222051a67f 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -26,7 +26,6 @@ abstract class ScheduleBase extends Action protected BrokerPool $publisher; protected BrokerPool $publisherMigrations; - protected BrokerPool $publisherFunctions; private ?Histogram $collectSchedulesTelemetryDuration = null; private ?Gauge $collectSchedulesTelemetryCount = null; @@ -46,7 +45,6 @@ abstract class ScheduleBase extends Action ->desc("Execute {$type}s scheduled in Appwrite") ->inject('publisher') ->inject('publisherMigrations') - ->inject('publisherFunctions') ->inject('dbForPlatform') ->inject('getProjectDB') ->inject('telemetry') @@ -69,14 +67,13 @@ abstract class ScheduleBase extends Action * 2. Create timer that sync all changes from 'schedules' collection to local copy. Only reading changes thanks to 'resourceUpdatedAt' attribute * 3. Create timer that prepares coroutines for soon-to-execute schedules. When it's ready, coroutine sleeps until exact time before sending request to worker. */ - public function action(BrokerPool $publisher, BrokerPool $publisherMigrations, BrokerPool $publisherFunctions, Database $dbForPlatform, callable $getProjectDB, Telemetry $telemetry): void + public function action(BrokerPool $publisher, BrokerPool $publisherMigrations, Database $dbForPlatform, callable $getProjectDB, Telemetry $telemetry): void { Console::title(\ucfirst(static::getSupportedResource()) . ' scheduler V1'); Console::success(APP_NAME . ' ' . \ucfirst(static::getSupportedResource()) . ' scheduler v1 has started'); $this->publisher = $publisher; $this->publisherMigrations = $publisherMigrations; - $this->publisherFunctions = $publisherFunctions; $this->scheduleTelemetryCount = $telemetry->createGauge('task.schedule.count'); $this->collectSchedulesTelemetryDuration = $telemetry->createHistogram('task.schedule.collect_schedules.duration', 's'); diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 14a4259e17..96a5a05f0e 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -30,7 +30,7 @@ class ScheduleExecutions extends ScheduleBase { $intervalEnd = (new \DateTime())->modify('+' . self::ENQUEUE_TIMER . ' seconds'); - $queueForFunctions = new Func($this->publisherFunctions); + $queueForFunctions = new Func($this->publisher); foreach ($this->schedules as $schedule) { if (!$schedule['active']) { diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index 6f072425e4..43f1025c08 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -90,7 +90,7 @@ class ScheduleFunctions extends ScheduleBase $this->updateProjectAccess($schedule['project'], $dbForPlatform); - $queueForFunctions = new Func($this->publisherFunctions); + $queueForFunctions = new Func($this->publisher); $queueForFunctions ->setType('schedule') diff --git a/tests/e2e/Services/Messaging/MessagingBase.php b/tests/e2e/Services/Messaging/MessagingBase.php index 728d3f0082..dc5ddb9d70 100644 --- a/tests/e2e/Services/Messaging/MessagingBase.php +++ b/tests/e2e/Services/Messaging/MessagingBase.php @@ -3,7 +3,6 @@ namespace Tests\E2E\Services\Messaging; use Appwrite\Messaging\Status as MessageStatus; -use Appwrite\Tests\Retry; use CURLFile; use Tests\E2E\Client; use Utopia\Database\DateTime; @@ -1191,7 +1190,6 @@ trait MessagingBase $this->assertEquals(MessageStatus::FAILED, $message['body']['status']); } - #[Retry(count: 3)] public function testUpdateScheduledAt(): void { // Create user