From edb533eaeaef90c7d8c95e215b95665f10b01113 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 6 Apr 2026 10:12:50 +0530 Subject: [PATCH] Use released Utopia coroutine adapter --- app/http.php | 2 +- composer.lock | 12 +-- .../Http/Adapter/SwooleCoroutine/Server.php | 91 ------------------- 3 files changed, 7 insertions(+), 98 deletions(-) delete mode 100644 src/Appwrite/Utopia/Http/Adapter/SwooleCoroutine/Server.php diff --git a/app/http.php b/app/http.php index 4bf056973e..425978d9af 100644 --- a/app/http.php +++ b/app/http.php @@ -5,7 +5,6 @@ require_once __DIR__ . '/init/span.php'; $registerRequestResources = require __DIR__ . '/init/resources/request.php'; -use Appwrite\Utopia\Http\Adapter\SwooleCoroutine\Server; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use Swoole\Table; @@ -22,6 +21,7 @@ use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; +use Utopia\Http\Adapter\SwooleCoroutine\Server; use Utopia\Http\Files; use Utopia\Http\Http; use Utopia\Logger\Log; diff --git a/composer.lock b/composer.lock index d113b99785..4c6d50e817 100644 --- a/composer.lock +++ b/composer.lock @@ -4325,16 +4325,16 @@ }, { "name": "utopia-php/http", - "version": "0.34.16", + "version": "0.34.17", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "2b4021ba3f9d476264ce9fd6703d6c79de9add7f" + "reference": "d3e4143b8b06d9823d0c29a06dacefa5a1b93677" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/2b4021ba3f9d476264ce9fd6703d6c79de9add7f", - "reference": "2b4021ba3f9d476264ce9fd6703d6c79de9add7f", + "url": "https://api.github.com/repos/utopia-php/http/zipball/d3e4143b8b06d9823d0c29a06dacefa5a1b93677", + "reference": "d3e4143b8b06d9823d0c29a06dacefa5a1b93677", "shasum": "" }, "require": { @@ -4373,9 +4373,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.34.16" + "source": "https://github.com/utopia-php/http/tree/0.34.17" }, - "time": "2026-03-20T10:39:07+00:00" + "time": "2026-04-06T04:40:23+00:00" }, { "name": "utopia-php/image", diff --git a/src/Appwrite/Utopia/Http/Adapter/SwooleCoroutine/Server.php b/src/Appwrite/Utopia/Http/Adapter/SwooleCoroutine/Server.php deleted file mode 100644 index 18ac2728d7..0000000000 --- a/src/Appwrite/Utopia/Http/Adapter/SwooleCoroutine/Server.php +++ /dev/null @@ -1,91 +0,0 @@ -server = new SwooleServer($host, $port, false, true); - $this->server->set(\array_merge($settings, [ - 'http_parse_cookie' => false, - ])); - $this->container = $container ?? new Container(); - } - - public function onRequest(callable $callback) - { - $this->server->handle('/', function (SwooleRequest $request, SwooleResponse $response) use ($callback) { - $requestContainer = new Container($this->container); - $requestContainer->set('swooleRequest', fn () => $request); - $requestContainer->set('swooleResponse', fn () => $response); - - Coroutine::getContext()[self::REQUEST_CONTAINER_CONTEXT_KEY] = $requestContainer; - - try { - \call_user_func($callback, new Request($request), new Response($response)); - } finally { - unset(Coroutine::getContext()[self::REQUEST_CONTAINER_CONTEXT_KEY]); - } - }); - } - - public function getContainer(): Container - { - if (Coroutine::getCid() !== -1) { - return Coroutine::getContext()[self::REQUEST_CONTAINER_CONTEXT_KEY] ?? $this->container; - } - - return $this->container; - } - - public function getServer(): SwooleServer - { - return $this->server; - } - - public function onStart(callable $callback) - { - $this->onStartCallback = $callback; - } - - public function start() - { - $startServer = function (): void { - if ($this->onStartCallback) { - \call_user_func($this->onStartCallback, $this); - } - - $this->server->start(); - }; - - if (Coroutine::getCid() !== -1) { - $startServer(); - - return; - } - - \Swoole\Coroutine\run($startServer); - } -}