Skip to content

Commit 229ca60

Browse files
committed
(refactor): Move Handler and SwooleCoroutine into Swoole sub-namespace
1 parent 1f2ec5f commit 229ca60

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

examples/http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Utopia\Proxy\Resolver;
66
use Utopia\Proxy\Resolver\Result;
77
use Utopia\Proxy\Server\HTTP\Swoole as HTTPServer;
8-
use Utopia\Proxy\Server\HTTP\SwooleCoroutine as HTTPCoroutineServer;
8+
use Utopia\Proxy\Server\HTTP\Swoole\Coroutine as HTTPCoroutineServer;
99

1010
/**
1111
* HTTP Proxy Server Example

src/Server/HTTP/Swoole.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Utopia\Proxy\Adapter;
99
use Utopia\Proxy\Protocol;
1010
use Utopia\Proxy\Resolver;
11+
use Utopia\Proxy\Server\HTTP\Swoole\Handler;
1112

1213
/**
1314
* High-performance HTTP proxy server (Swoole Implementation)
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<?php
22

3-
namespace Utopia\Proxy\Server\HTTP;
3+
namespace Utopia\Proxy\Server\HTTP\Swoole;
44

5-
use Swoole\Coroutine;
5+
use Swoole\Coroutine as SwooleCoroutine;
66
use Swoole\Coroutine\Http\Server as CoroutineServer;
77
use Utopia\Console;
88
use Utopia\Proxy\Adapter;
99
use Utopia\Proxy\Protocol;
1010
use Utopia\Proxy\Resolver;
11+
use Utopia\Proxy\Server\HTTP\Config;
1112

1213
/**
1314
* High-performance HTTP proxy server (Swoole Coroutine Implementation)
1415
*
1516
* Example:
1617
* ```php
1718
* $resolver = new MyFunctionResolver();
18-
* $server = new SwooleCoroutine($resolver, new Config(host: '0.0.0.0', port: 80));
19+
* $server = new Coroutine($resolver, new Config(host: '0.0.0.0', port: 80));
1920
* $server->start();
2021
* ```
2122
*/
22-
class SwooleCoroutine
23+
class Coroutine
2324
{
2425
use Handler;
2526

@@ -100,15 +101,15 @@ public function onWorkerStart(int $workerId = 0): void
100101

101102
public function start(): void
102103
{
103-
if (Coroutine::getCid() > 0) {
104+
if (SwooleCoroutine::getCid() > 0) {
104105
$this->onStart();
105106
$this->onWorkerStart(0);
106107
$this->server->start();
107108

108109
return;
109110
}
110111

111-
Coroutine\run(function (): void {
112+
SwooleCoroutine\run(function (): void {
112113
$this->onStart();
113114
$this->onWorkerStart(0);
114115
$this->server->start();
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Utopia\Proxy\Server\HTTP;
3+
namespace Utopia\Proxy\Server\HTTP\Swoole;
44

55
use Swoole\Coroutine\Channel;
66
use Swoole\Coroutine\Client as CoroutineClient;
@@ -9,6 +9,8 @@
99
use Swoole\Http\Response;
1010
use Utopia\Console;
1111
use Utopia\Proxy\Adapter;
12+
use Utopia\Proxy\Server\HTTP\Config;
13+
use Utopia\Proxy\Server\HTTP\Telemetry;
1214
use Utopia\Validator\Hostname;
1315

1416
/**

0 commit comments

Comments
 (0)