44
55use Swoole \Coroutine \Channel ;
66use Swoole \Coroutine \Client as CoroutineClient ;
7+ use Swoole \Coroutine \Http \Client as HttpClient ;
78use Swoole \Http \Request ;
89use Swoole \Http \Response ;
10+ use Swoole \Http \Server ;
911use Utopia \Proxy \Adapter ;
1012use Utopia \Proxy \Protocol ;
1113use Utopia \Proxy \Resolver ;
2224 */
2325class Swoole
2426{
25- protected \ Swoole \ Http \ Server $ server ;
27+ protected Server $ server ;
2628
2729 protected Adapter $ adapter ;
2830
@@ -36,7 +38,7 @@ public function __construct(
3638 ?Config $ config = null ,
3739 ) {
3840 $ this ->config = $ config ?? new Config ();
39- $ this ->server = new \ Swoole \ Http \ Server (
41+ $ this ->server = new Server (
4042 $ this ->config ->host ,
4143 $ this ->config ->port ,
4244 $ this ->config ->serverMode ,
@@ -79,14 +81,14 @@ protected function configure(): void
7981 $ this ->server ->on ('request ' , $ this ->onRequest (...));
8082 }
8183
82- public function onStart (\ Swoole \ Http \ Server $ server ): void
84+ public function onStart (Server $ server ): void
8385 {
8486 echo "HTTP Proxy Server started at http:// {$ this ->config ->host }: {$ this ->config ->port }\n" ;
8587 echo "Workers: {$ this ->config ->workers }\n" ;
8688 echo "Max connections: {$ this ->config ->maxConnections }\n" ;
8789 }
8890
89- public function onWorkerStart (\ Swoole \ Http \ Server $ server , int $ workerId ): void
91+ public function onWorkerStart (Server $ server , int $ workerId ): void
9092 {
9193 $ this ->adapter = new Adapter ($ this ->resolver , name: 'HTTP ' , protocol: Protocol::HTTP );
9294
@@ -198,8 +200,8 @@ protected function forwardRequest(Request $request, Response $response, string $
198200
199201 $ isNewClient = false ;
200202 $ client = $ pool ->pop ($ this ->config ->poolTimeout );
201- if (!$ client instanceof \ Swoole \ Coroutine \ Http \Client ) {
202- $ client = new \ Swoole \ Coroutine \ Http \ Client ($ host , $ port );
203+ if (!$ client instanceof HttpClient ) {
204+ $ client = new HttpClient ($ host , $ port );
203205 $ client ->set ([
204206 'timeout ' => $ this ->config ->timeout ,
205207 'keep_alive ' => $ this ->config ->keepAlive ,
0 commit comments