From ec65071ae342eb5ec22c04aa2b6af477b701ea8f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 17 Apr 2025 23:59:43 +1200 Subject: [PATCH] Revert "Add publisher consumer pool adapter" This reverts commit fe26dcb50aa057340fe5eb087f9c3181a8e8b6ef. --- app/worker.php | 24 +++++++++++++++--------- composer.json | 2 +- composer.lock | 29 +++++++++++------------------ 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/app/worker.php b/app/worker.php index 79f8fe0d85..ddac70b8d3 100644 --- a/app/worker.php +++ b/app/worker.php @@ -410,21 +410,25 @@ try { * - _APP_WORKER_PER_CORE The number of worker processes per core (ignored if _APP_WORKERS_NUM is set) * - _APP_QUEUE_NAME The name of the queue to read for database events */ - $platform->init( - type: Service::TYPE_WORKER, - params: ['workerName' => strtolower($workerName) ?? null], - server: new Server(new QueuePool( - $pools->get('consumer'), - workerNum: System::getEnv('_APP_WORKERS_NUM', 1), - queue: $queueName - )) - ); + $platform->init(Service::TYPE_WORKER, [ + 'workersNum' => System::getEnv('_APP_WORKERS_NUM', 1), + 'connection' => $pools->get('consumer')->pop()->getResource(), + 'workerName' => strtolower($workerName) ?? null, + 'queueName' => $queueName + ]); } catch (\Throwable $e) { Console::error($e->getMessage() . ', File: ' . $e->getFile() . ', Line: ' . $e->getLine()); } $worker = $platform->getWorker(); +$worker + ->shutdown() + ->inject('pools') + ->action(function (Group $pools) { + $pools->get('consumer')->reclaim(); + }); + $worker ->error() ->inject('error') @@ -433,6 +437,8 @@ $worker ->inject('pools') ->inject('project') ->action(function (Throwable $error, ?Logger $logger, Log $log, Group $pools, Document $project) use ($worker, $queueName) { + $pools->get('consumer')->reclaim(); + $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); if ($logger) { diff --git a/composer.json b/composer.json index 5d91aa8116..afeee6b8fc 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "utopia-php/messaging": "0.16.*", "utopia-php/migration": "0.8.*", "utopia-php/orchestration": "0.9.*", - "utopia-php/platform": "dev-feat-custom-server as 0.7.4", + "utopia-php/platform": "0.7.*", "utopia-php/pools": "0.8.*", "utopia-php/preloader": "0.2.*", "utopia-php/queue": "dev-feat-pool-adapter as 0.9.1", diff --git a/composer.lock b/composer.lock index 9ad06f5317..5fd0538e06 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "127ac05400882555232b9d9a9d9e5c0e", + "content-hash": "c8a1e0dfdd111062fe7a969e17ddc2b5", "packages": [ { "name": "adhocore/jwt", @@ -4058,16 +4058,16 @@ }, { "name": "utopia-php/platform", - "version": "dev-feat-custom-server", + "version": "0.7.4", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "1afcdb43643531c82d5beaab30c2cfb5bf40ab52" + "reference": "a5b93d8177702ec458c3af9137663133c012b71b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/1afcdb43643531c82d5beaab30c2cfb5bf40ab52", - "reference": "1afcdb43643531c82d5beaab30c2cfb5bf40ab52", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/a5b93d8177702ec458c3af9137663133c012b71b", + "reference": "a5b93d8177702ec458c3af9137663133c012b71b", "shasum": "" }, "require": { @@ -4102,9 +4102,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/feat-custom-server" + "source": "https://github.com/utopia-php/platform/tree/0.7.4" }, - "time": "2025-04-17T07:58:12+00:00" + "time": "2025-03-13T13:00:12+00:00" }, { "name": "utopia-php/pools", @@ -4217,12 +4217,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "80cc1fb1053950f977f0d027bb4a7f7c91c1e794" + "reference": "b192e36f646d3f5da80f70e3a69e0065b23a3612" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/80cc1fb1053950f977f0d027bb4a7f7c91c1e794", - "reference": "80cc1fb1053950f977f0d027bb4a7f7c91c1e794", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/b192e36f646d3f5da80f70e3a69e0065b23a3612", + "reference": "b192e36f646d3f5da80f70e3a69e0065b23a3612", "shasum": "" }, "require": { @@ -4275,7 +4275,7 @@ "issues": "https://github.com/utopia-php/queue/issues", "source": "https://github.com/utopia-php/queue/tree/feat-pool-adapter" }, - "time": "2025-04-17T08:43:02+00:00" + "time": "2025-04-17T11:55:59+00:00" }, { "name": "utopia-php/registry", @@ -8127,12 +8127,6 @@ } ], "aliases": [ - { - "package": "utopia-php/platform", - "version": "dev-feat-custom-server", - "alias": "0.7.4", - "alias_normalized": "0.7.4.0" - }, { "package": "utopia-php/queue", "version": "dev-feat-pool-adapter", @@ -8142,7 +8136,6 @@ ], "minimum-stability": "stable", "stability-flags": { - "utopia-php/platform": 20, "utopia-php/queue": 20 }, "prefer-stable": false,