From f224c09c10eebf36905d1d4a01164a4440c75bec Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 3 Jul 2025 14:08:54 -0400 Subject: [PATCH] Use correct publisher in schedule tasks --- src/Appwrite/Platform/Tasks/ScheduleExecutions.php | 9 ++++++++- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 27a7c1dbf1..c9b795f684 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -6,6 +6,7 @@ use Appwrite\Event\Func; use Swoole\Coroutine as Co; use Utopia\Database\Database; use Utopia\Pools\Group; +use Utopia\System\System; class ScheduleExecutions extends ScheduleBase { @@ -29,9 +30,15 @@ class ScheduleExecutions extends ScheduleBase protected function enqueueResources(Group $pools, Database $dbForPlatform, callable $getProjectDB): void { - $queueForFunctions = new Func($this->publisher); $intervalEnd = (new \DateTime())->modify('+' . self::ENQUEUE_TIMER . ' seconds'); + $isRedisFallback = \str_contains(System::getEnv('_APP_WORKER_REDIS_FALLBACK', ''), 'functions'); + + $queueForFunctions = new Func($isRedisFallback + ? $this->publisherRedis + : $this->publisher + ); + foreach ($this->schedules as $schedule) { if (!$schedule['active']) { $dbForPlatform->deleteDocument( diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index 7812b27832..80d5b32d03 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -8,6 +8,8 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; +use Utopia\Queue\Queue; +use Utopia\System\System; class ScheduleFunctions extends ScheduleBase { @@ -90,7 +92,12 @@ class ScheduleFunctions extends ScheduleBase $this->updateProjectAccess($schedule['project'], $dbForPlatform); - $queueForFunctions = new Func($this->publisher); + $isRedisFallback = \str_contains(System::getEnv('_APP_WORKER_REDIS_FALLBACK', ''), 'functions'); + + $queueForFunctions = new Func($isRedisFallback + ? $this->publisherRedis + : $this->publisher + ); $queueForFunctions ->setType('schedule')