Merge pull request #12497 from appwrite/feat/upgrade-queue

Upgrade utopia-php/queue to 0.20.0
This commit is contained in:
Luke B. Silver authored and GitHub committed 2026-06-04 14:32:13 +01:00
commit 82ef70565d
5 files changed
+34 -302

No files matched your search

+5 -11
View File
@@ -222,12 +222,6 @@ $register->set('pools', function () {
'multiple' => false,
'schemes' => ['redis'],
],
'consumer' => [
'type' => 'consumer',
'dsns' => $fallbackForRedis,
'multiple' => false,
'schemes' => ['redis'],
],
'pubsub' => [
'type' => 'pubsub',
'dsns' => $fallbackForRedis,
@@ -344,11 +338,8 @@ $register->set('pools', function () {
// PubSub workers hold one long-lived subscribed connection and also need
// spare capacity for publishes from the same process.
// Consumer pools lease one connection per consume coroutine for the
// lifetime of the worker, plus headroom for queue-size reads.
$connectionPoolSize = match ($type) {
'pubsub' => max(2, $poolSize),
'consumer' => $poolSize + 2,
default => $poolSize,
};
@@ -372,9 +363,12 @@ $register->set('pools', function () {
default => null
};
case 'publisher':
case 'consumer':
// Publishers never block on receive, so one connection backs both broker slots.
return match ($dsn->getScheme()) {
'redis' => new Queue\Broker\Redis(new Queue\Connection\Redis($dsn->getHost(), $dsn->getPort())),
'redis' => (function () use ($dsn) {
$connection = new Queue\Connection\Redis($dsn->getHost(), $dsn->getPort());
return new Queue\Broker\Redis($connection, $connection);
})(),
default => null
};
case 'cache':
+10 -26
View File
@@ -12,9 +12,10 @@ use Utopia\Database\Validator\Authorization;
use Utopia\Logger\Log;
use Utopia\Logger\Logger;
use Utopia\Platform\Service;
use Utopia\Pools\Group;
use Utopia\Queue\Adapter\Swoole;
use Utopia\Queue\Broker\Pool as BrokerPool;
use Utopia\Queue\Broker\Redis as BrokerRedis;
use Utopia\Queue\Connection\Locking;
use Utopia\Queue\Connection\Redis as RedisConnection;
use Utopia\Queue\Server;
use Utopia\Span\Span;
use Utopia\System\System;
@@ -38,22 +39,6 @@ $container->set('project', fn () => new Document([]), []);
$container->set('log', fn () => new Log(), []);
$container->set('consumer', function (Group $pools) {
return new BrokerPool(consumer: $pools->get('consumer'));
}, ['pools']);
$container->set('consumerDatabases', function (BrokerPool $consumer) {
return $consumer;
}, ['consumer']);
$container->set('consumerMigrations', function (BrokerPool $consumer) {
return $consumer;
}, ['consumer']);
$container->set('consumerStatsUsage', function (BrokerPool $consumer) {
return $consumer;
}, ['consumer']);
$container->set('certificates', function () {
$email = System::getEnv('_APP_EMAIL_CERTIFICATES', System::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS'));
if (empty($email)) {
@@ -80,16 +65,15 @@ if (\str_starts_with($workerName, 'databases')) {
$queueName = System::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName));
}
/** @var \Utopia\Pools\Group $pools */
$pools = $container->get('pools');
$redisHost = System::getEnv('_APP_REDIS_HOST', 'redis');
$redisPort = (int) System::getEnv('_APP_REDIS_PORT', 6379);
// Each consume coroutine leases its own broker connection from the pool for
// the lifetime of its consume loop, so concurrent coroutines never share a
// connection. The publisher side backs the queue-depth telemetry gauge.
// A dedicated connection drives the blocking receive loop; a lock-guarded one
// serializes acks/publishes from the per-message coroutines.
$adapter = new Swoole(
new BrokerPool(
publisher: $pools->get('consumer'),
consumer: $pools->get('consumer'),
new BrokerRedis(
receive: new RedisConnection($redisHost, $redisPort),
commands: new Locking(new RedisConnection($redisHost, $redisPort)),
),
System::getEnv('_APP_WORKERS_NUM', 1),
$queueName,
+2 -2
View File
@@ -78,11 +78,11 @@
"utopia-php/logger": "0.8.*",
"utopia-php/messaging": "1.0.*",
"utopia-php/migration": "1.*",
"utopia-php/platform": "1.0.0-rc4",
"utopia-php/platform": "1.0.0-rc5",
"utopia-php/pools": "1.*",
"utopia-php/span": "1.1.*",
"utopia-php/preloader": "0.2.*",
"utopia-php/queue": "0.19.*",
"utopia-php/queue": "0.20.*",
"utopia-php/servers": "0.4.*",
"utopia-php/registry": "0.5.*",
"utopia-php/storage": "2.*",
Generated
+15 -257
View File
@@ -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": "5cc3d8a63a229bf9363c4baa8d985f7c",
"content-hash": "182aa10ce3b77b8cf38eefc25944e939",
"packages": [
{
"name": "adhocore/jwt",
@@ -1703,137 +1703,6 @@
},
"time": "2025-09-24T15:06:41+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.100",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a",
"shasum": ""
},
"require": {
"php": ">= 7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"support": {
"email": "info@paragonie.com",
"issues": "https://github.com/paragonie/random_compat/issues",
"source": "https://github.com/paragonie/random_compat"
},
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "php-amqplib/php-amqplib",
"version": "v3.7.4",
"source": {
"type": "git",
"url": "https://github.com/php-amqplib/php-amqplib.git",
"reference": "381b6f7c600e0e0c7463cdd7f7a1a3bc6268e5fd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/381b6f7c600e0e0c7463cdd7f7a1a3bc6268e5fd",
"reference": "381b6f7c600e0e0c7463cdd7f7a1a3bc6268e5fd",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-sockets": "*",
"php": "^7.2||^8.0",
"phpseclib/phpseclib": "^2.0|^3.0"
},
"conflict": {
"php": "7.4.0 - 7.4.1"
},
"replace": {
"videlalvaro/php-amqplib": "self.version"
},
"require-dev": {
"ext-curl": "*",
"nategood/httpful": "^0.2.20",
"phpunit/phpunit": "^7.5|^9.5",
"squizlabs/php_codesniffer": "^3.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"PhpAmqpLib\\": "PhpAmqpLib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "Alvaro Videla",
"role": "Original Maintainer"
},
{
"name": "Raúl Araya",
"email": "nubeiro@gmail.com",
"role": "Maintainer"
},
{
"name": "Luke Bakken",
"email": "luke@bakken.io",
"role": "Maintainer"
},
{
"name": "Ramūnas Dronga",
"email": "github@ramuno.lt",
"role": "Maintainer"
}
],
"description": "Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.",
"homepage": "https://github.com/php-amqplib/php-amqplib/",
"keywords": [
"message",
"queue",
"rabbitmq"
],
"support": {
"issues": "https://github.com/php-amqplib/php-amqplib/issues",
"source": "https://github.com/php-amqplib/php-amqplib/tree/v3.7.4"
},
"time": "2025-11-23T17:00:56+00:00"
},
{
"name": "php-http/discovery",
"version": "1.20.0",
@@ -1994,116 +1863,6 @@
],
"time": "2023-11-25T22:23:28+00:00"
},
{
"name": "phpseclib/phpseclib",
"version": "3.0.52",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "2adaefc83df2ec548558307690f376dd7d4f4fce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/2adaefc83df2ec548558307690f376dd7d4f4fce",
"reference": "2adaefc83df2ec548558307690f376dd7d4f4fce",
"shasum": ""
},
"require": {
"paragonie/constant_time_encoding": "^1|^2|^3",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": ">=5.6.1"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"ext-dom": "Install the DOM extension to load XML formatted public keys.",
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
},
"type": "library",
"autoload": {
"files": [
"phpseclib/bootstrap.php"
],
"psr-4": {
"phpseclib3\\": "phpseclib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.52"
},
"funding": [
{
"url": "https://github.com/terrafrost",
"type": "github"
},
{
"url": "https://www.patreon.com/phpseclib",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
"type": "tidelift"
}
],
"time": "2026-04-27T07:02:15+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",
@@ -4774,16 +4533,16 @@
},
{
"name": "utopia-php/platform",
"version": "1.0.0-rc4",
"version": "1.0.0-rc5",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/platform.git",
"reference": "455c84f8d1cdaec6fc2c39587a78aa5ef263ddd0"
"reference": "edf46c6e9c62af1cec1cbd1386a84c730d76a9f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/platform/zipball/455c84f8d1cdaec6fc2c39587a78aa5ef263ddd0",
"reference": "455c84f8d1cdaec6fc2c39587a78aa5ef263ddd0",
"url": "https://api.github.com/repos/utopia-php/platform/zipball/edf46c6e9c62af1cec1cbd1386a84c730d76a9f8",
"reference": "edf46c6e9c62af1cec1cbd1386a84c730d76a9f8",
"shasum": ""
},
"require": {
@@ -4792,7 +4551,7 @@
"php": ">=8.3",
"utopia-php/cli": "0.23.*",
"utopia-php/http": "^2.0@RC",
"utopia-php/queue": "^0.19",
"utopia-php/queue": "^0.20",
"utopia-php/servers": "0.4.*"
},
"require-dev": {
@@ -4819,9 +4578,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/platform/issues",
"source": "https://github.com/utopia-php/platform/tree/1.0.0-rc4"
"source": "https://github.com/utopia-php/platform/tree/1.0.0-rc5"
},
"time": "2026-06-02T20:19:26+00:00"
"time": "2026-06-04T13:00:46+00:00"
},
{
"name": "utopia-php/pools",
@@ -4977,21 +4736,20 @@
},
{
"name": "utopia-php/queue",
"version": "0.19.0",
"version": "0.20.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/queue.git",
"reference": "cd4248af69006b2568c3486a675f27cb21191859"
"reference": "d4da9e8d4a8879eb529ec1cda6b93cad2cf8d940"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/cd4248af69006b2568c3486a675f27cb21191859",
"reference": "cd4248af69006b2568c3486a675f27cb21191859",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/d4da9e8d4a8879eb529ec1cda6b93cad2cf8d940",
"reference": "d4da9e8d4a8879eb529ec1cda6b93cad2cf8d940",
"shasum": ""
},
"require": {
"php": ">=8.3",
"php-amqplib/php-amqplib": "^3.7",
"php": ">=8.4",
"utopia-php/di": "0.3.*",
"utopia-php/lock": "0.2.*",
"utopia-php/pools": "1.*",
@@ -5038,9 +4796,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/queue/issues",
"source": "https://github.com/utopia-php/queue/tree/0.19.0"
"source": "https://github.com/utopia-php/queue/tree/0.20.0"
},
"time": "2026-06-02T20:12:18+00:00"
"time": "2026-06-04T12:33:31+00:00"
},
{
"name": "utopia-php/registry",
+2 -6
View File
@@ -10,8 +10,6 @@ use Utopia\Database\Document;
use Utopia\Database\Exception\Structure;
use Utopia\Platform\Action;
use Utopia\Queue\Message;
use Utopia\Queue\Result\Commit;
use Utopia\Queue\Result\NoCommit;
use Utopia\System\System;
class Audits extends Action
@@ -51,12 +49,11 @@ class Audits extends Action
/**
* @param Message $message
* @param callable(Document): \Utopia\Audit\Audit $getAudit
* @return Commit|NoCommit
* @throws Throwable
* @throws \Utopia\Database\Exception
* @throws Structure
*/
public function action(Message $message, callable $getAudit): Commit|NoCommit
public function action(Message $message, callable $getAudit): void
{
$payload = $message->getPayload();
@@ -148,7 +145,7 @@ class Audits extends Action
}
if (!$shouldProcessBatch) {
return new NoCommit();
return;
}
foreach ($this->logs as $sequence => $projectLogs) {
@@ -168,6 +165,5 @@ class Audits extends Action
}
$this->lastTriggeredTime = time();
return new Commit();
}
}