mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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.
This commit is contained in:
1 parent
7fd39aa632
commit
6cc05c74fe
2 files changed
+29
-1
No files matched your search
+1
-1
@@ -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",
|
||||
|
||||
@@ -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<string>
|
||||
*/
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user