From bdd63a8bd6ed513c960a2e53c0cf8c24763e2b63 Mon Sep 17 00:00:00 2001 From: "Luke B. Silver" <22452787+loks0n@users.noreply.github.com> Date: Wed, 2 Sep 2026 13:26:09 +0100 Subject: [PATCH] refactor(queues): remove intermediate publisher resources (#13449) --- app/init/resources.php | 20 +++----------------- app/init/resources/request.php | 8 ++++---- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/app/init/resources.php b/app/init/resources.php index 757dc404c2..35252bec17 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -109,20 +109,6 @@ $container->set('authorization', fn () => new Authorization(), []); $container->set('publisher', fn (Group $pools) => new BrokerPool(publisher: $pools->get('publisher')), ['pools']); -$container->set('publisherDatabases', fn (Publisher $publisher) => $publisher, ['publisher']); - -$container->set('publisherFunctions', fn (Publisher $publisher) => $publisher, ['publisher']); - -$container->set('publisherMigrations', fn (Publisher $publisher) => $publisher, ['publisher']); - -$container->set('publisherMails', fn (Publisher $publisher) => $publisher, ['publisher']); - -$container->set('publisherDeletes', fn (Publisher $publisher) => $publisher, ['publisher']); - -$container->set('publisherMessaging', fn (Publisher $publisher) => $publisher, ['publisher']); - -$container->set('publisherWebhooks', fn (Publisher $publisher) => $publisher, ['publisher']); - $container->set('publisherForAudits', fn (Publisher $publisher) => new AuditPublisher( $publisher, new Queue(System::getEnv('_APP_AUDITS_QUEUE_NAME', Event::AUDITS_QUEUE_NAME)) @@ -204,10 +190,10 @@ $container->set('publisherForJobs', fn (Publisher $publisher) => new JobsPublish new Queue(System::getEnv('_APP_JOBS_QUEUE_NAME', Event::JOBS_QUEUE_NAME)) ), ['publisher']); -$container->set('publisherForDatabase', fn (Publisher $publisherDatabases) => new DatabasePublisher( - $publisherDatabases, +$container->set('publisherForDatabase', fn (Publisher $publisher) => new DatabasePublisher( + $publisher, new Queue(System::getEnv('_APP_DATABASE_QUEUE_NAME', Event::DATABASE_QUEUE_NAME)) -), ['publisherDatabases']); +), ['publisher']); $container->set('publisherForDeletes', fn (Publisher $publisher) => new DeletePublisher( $publisher, diff --git a/app/init/resources/request.php b/app/init/resources/request.php index 8039571243..8aa7f7cf70 100644 --- a/app/init/resources/request.php +++ b/app/init/resources/request.php @@ -672,7 +672,7 @@ return function (Container $context): void { return; }, ['user', 'store', 'proofForToken']); - $context->set('dbForProject', function (DatabaseFactory $databaseFactory, Database $dbForPlatform, Document $project, Response $response, Publisher $publisher, Publisher $publisherFunctions, Publisher $publisherWebhooks, Event $queueForEvents, FunctionPublisher $publisherForFunctions, Webhook $queueForWebhooks, Realtime $queueForRealtime, UsageContext $usage, Request $request) { + $context->set('dbForProject', function (DatabaseFactory $databaseFactory, Database $dbForPlatform, Document $project, Response $response, Publisher $publisher, Event $queueForEvents, FunctionPublisher $publisherForFunctions, Webhook $queueForWebhooks, Realtime $queueForRealtime, UsageContext $usage, Request $request) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForPlatform; } @@ -796,7 +796,7 @@ return function (Container $context): void { // 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); - $queueForWebhooks = new Webhook($publisherWebhooks); + $queueForWebhooksClone = clone $queueForWebhooks; $queueForRealtime = new Realtime(); $database @@ -811,7 +811,7 @@ return function (Container $context): void { $response, $queueForEventsClone->from($queueForEvents), $publisherForFunctions, - $queueForWebhooks->from($queueForEvents), + $queueForWebhooksClone->from($queueForEvents), $queueForRealtime->from($queueForEvents) )) ->on(Database::EVENT_DOCUMENT_CREATE, 'purge-function-events-cache', fn ($event, $document) => $functionsEventsCacheListener($event, $document, $project, $database)) @@ -819,7 +819,7 @@ return function (Container $context): void { ->on(Database::EVENT_DOCUMENT_DELETE, 'purge-function-events-cache', fn ($event, $document) => $functionsEventsCacheListener($event, $document, $project, $database)); return $database; - }, ['databaseFactory', 'dbForPlatform', 'project', 'response', 'publisher', 'publisherFunctions', 'publisherWebhooks', 'queueForEvents', 'publisherForFunctions', 'queueForWebhooks', 'queueForRealtime', 'usage', 'request']); + }, ['databaseFactory', 'dbForPlatform', 'project', 'response', 'publisher', 'queueForEvents', 'publisherForFunctions', 'queueForWebhooks', 'queueForRealtime', 'usage', 'request']); $context->set('schema', function ($utopia, $dbForProject, $authorization) {