diff --git a/app/http.php b/app/http.php index 91da4e8cab..008a355550 100644 --- a/app/http.php +++ b/app/http.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/../vendor/autoload.php'; -use Appwrite\Utopia\Queue\Connections; +use Appwrite\Utopia\Pools\Connections; use Appwrite\Utopia\Response; use Swoole\Process; use Swoole\Http\Server; diff --git a/app/init.php b/app/init.php index 86f5ad5b1e..829911f904 100644 --- a/app/init.php +++ b/app/init.php @@ -33,7 +33,7 @@ use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\Origin; use Appwrite\OpenSSL\OpenSSL; use Appwrite\URL\URL as AppwriteURL; -use Appwrite\Utopia\Queue\Connections; +use Appwrite\Utopia\Pools\Connections; use Utopia\App; use Utopia\Logger\Logger; use Utopia\Cache\Adapter\Redis as RedisCache; diff --git a/app/worker.php b/app/worker.php index 2982f7af1f..99f4154c98 100644 --- a/app/worker.php +++ b/app/worker.php @@ -16,7 +16,7 @@ use Appwrite\Event\Phone; use Appwrite\Event\Usage; use Appwrite\Event\UsageDump; use Appwrite\Platform\Appwrite; -use Appwrite\Utopia\Queue\Connections; +use Appwrite\Utopia\Pools\Connections; use Swoole\Runtime; use Utopia\App; use Utopia\Cache\Adapter\Sharding; diff --git a/src/Appwrite/Utopia/Queue/Connections.php b/src/Appwrite/Utopia/Pools/Connections.php similarity index 69% rename from src/Appwrite/Utopia/Queue/Connections.php rename to src/Appwrite/Utopia/Pools/Connections.php index e3d5740b97..bf9a44bdb8 100644 --- a/src/Appwrite/Utopia/Queue/Connections.php +++ b/src/Appwrite/Utopia/Pools/Connections.php @@ -1,6 +1,6 @@ connections[$id] ?? throw new \Exception("Connection '{$id}' not found"); - } - /** * @param string $id * @return self @@ -41,14 +31,20 @@ class Connections return $this; } + public function count(): int + { + return \count($this->connections); + } + /** * @return self * @throws \Exception */ public function reclaim(): self { - foreach ($this->connections as $connection) { + foreach ($this->connections as $id => $connection) { $connection->reclaim(); + unset($this->connections[$id]); } return $this;