From 6cc05c74fe6a59d5f61ce41c5913664cd3b8c933 Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Fri, 18 Sep 2026 14:58:35 +0200 Subject: [PATCH] chore(queue): move to utopia-php/queue 3.0 The major adds rightPopMany() and incrementBy() to Connection, which is the whole of its breaking surface here: InMemoryConnection is the only implementation in this repository, and WorkerConcurrencyTest drives it. Consumer is unchanged, so FakeConsumer in InitJobsTest needs nothing. 3.0 brings PermanentFailure (a handler can end a message's life rather than spend its whole redelivery budget on work that cannot succeed), a pluggable envelope codec, and batched receive -- none of which this commit takes up. It moves the floor so applications built on server-ce can. The lock is not updated yet: utopia-php/platform 1.0.0-rc20 caps queue at ^2.0.0, so this needs rc21 (utopia-php/monorepo#301) first. --- composer.json | 2 +- tests/extensions/Queue/InMemoryConnection.php | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2397a2cf06..89c128d45f 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,7 @@ "utopia-php/platform": "1.0.0-rc20", "utopia-php/pools": "2.*", "utopia-php/span": "^4.2", - "utopia-php/queue": "^2.2.4", + "utopia-php/queue": "^3.0.0", "utopia-php/servers": "0.4.*", "utopia-php/registry": "0.5.*", "utopia-php/storage": "^4.0", diff --git a/tests/extensions/Queue/InMemoryConnection.php b/tests/extensions/Queue/InMemoryConnection.php index bb76a899e5..006a5d07ab 100644 --- a/tests/extensions/Queue/InMemoryConnection.php +++ b/tests/extensions/Queue/InMemoryConnection.php @@ -88,6 +88,29 @@ final class InMemoryConnection implements Connection return \is_string($value) ? $value : false; } + /** + * Pop up to $count payloads from the tail, in pop order. + * + * Fewer than asked — including none — is the ordinary answer on a list that + * holds fewer, matching what LMPOP does for the real connection. + * + * @return list + */ + public function rightPopMany(string $queue, int $count, int $timeout): array + { + $batch = []; + for ($taken = 0; $taken < $count; $taken++) { + $value = $this->pop($queue, fromTail: true); + if (!\is_string($value)) { + break; + } + + $batch[] = $value; + } + + return $batch; + } + public function rightPopLeftPush(string $queue, string $destination, int $timeout): string|false { $value = $this->rightPop($queue, $timeout); @@ -185,6 +208,11 @@ final class InMemoryConnection implements Connection return $this->counters[$key] = ($this->counters[$key] ?? 0) + 1; } + public function incrementBy(string $key, int $by): int + { + return $this->counters[$key] = ($this->counters[$key] ?? 0) + $by; + } + public function decrement(string $key): int { return $this->counters[$key] = ($this->counters[$key] ?? 0) - 1;