From 363d7398b6e6fdfa7f19efeee1b88618db745ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thanh=20Tr=E1=BA=A7n?= <42226341+ging-dev@users.noreply.github.com> Date: Fri, 31 May 2024 23:22:08 +0700 Subject: [PATCH] Revert #195 (#205) * Revert #195 * make async dev dependency --------- Co-authored-by: Joe Dixon --- composer.json | 2 +- .../Reverb/Console/Commands/StartServer.php | 18 ++++++++---------- src/Servers/Reverb/Http/Server.php | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 3770fe2c..3d7e27ca 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "laravel/prompts": "^0.1.15", "pusher/pusher-php-server": "^7.2", "ratchet/rfc6455": "^0.3.1", - "react/async": "^4.2", "react/promise-timer": "^1.10", "react/socket": "^1.14", "symfony/console": "^6.0|^7.0", @@ -40,6 +39,7 @@ "pestphp/pest": "^2.0", "phpstan/phpstan": "^1.10", "ratchet/pawl": "^0.4.1", + "react/async": "^4.2", "react/http": "^1.9" }, "autoload": { diff --git a/src/Servers/Reverb/Console/Commands/StartServer.php b/src/Servers/Reverb/Console/Commands/StartServer.php index 5da26d1e..d4209444 100644 --- a/src/Servers/Reverb/Console/Commands/StartServer.php +++ b/src/Servers/Reverb/Console/Commands/StartServer.php @@ -20,8 +20,6 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\SignalableCommandInterface; -use function React\Async\async; - #[AsCommand(name: 'reverb:start')] class StartServer extends Command implements SignalableCommandInterface { @@ -92,10 +90,10 @@ protected function ensureHorizontalScalability(LoopInterface $loop): void */ protected function ensureStaleConnectionsAreCleaned(LoopInterface $loop): void { - $loop->addPeriodicTimer(60, async(function () { + $loop->addPeriodicTimer(60, function () { PruneStaleConnections::dispatch(); PingInactiveConnections::dispatch(); - })); + }); } /** @@ -105,7 +103,7 @@ protected function ensureRestartCommandIsRespected(Server $server, LoopInterface { $lastRestart = Cache::get('laravel:reverb:restart'); - $loop->addPeriodicTimer(5, async(function () use ($server, $host, $port, $lastRestart) { + $loop->addPeriodicTimer(5, function () use ($server, $host, $port, $lastRestart) { if ($lastRestart === Cache::get('laravel:reverb:restart')) { return; } @@ -115,7 +113,7 @@ protected function ensureRestartCommandIsRespected(Server $server, LoopInterface $server->stop(); $this->components->info("Stopping server on {$host}:{$port}"); - })); + }); } /** @@ -143,9 +141,9 @@ protected function ensurePulseEventsAreCollected(LoopInterface $loop, int $inter return; } - $loop->addPeriodicTimer($interval, async(function () { + $loop->addPeriodicTimer($interval, function () { $this->laravel->make(\Laravel\Pulse\Pulse::class)->ingest(); - })); + }); } /** @@ -157,9 +155,9 @@ protected function ensureTelescopeEntriesAreCollected(LoopInterface $loop, int $ return; } - $loop->addPeriodicTimer($interval, async(function () { + $loop->addPeriodicTimer($interval, function () { \Laravel\Telescope\Telescope::store($this->laravel->make(\Laravel\Telescope\Contracts\EntriesRepository::class)); - })); + }); } /** diff --git a/src/Servers/Reverb/Http/Server.php b/src/Servers/Reverb/Http/Server.php index bdb44d8a..182a849f 100644 --- a/src/Servers/Reverb/Http/Server.php +++ b/src/Servers/Reverb/Http/Server.php @@ -27,7 +27,7 @@ public function __construct(protected ServerInterface $socket, protected Router $this->loop = $loop ?: Loop::get(); - $this->loop->addPeriodicTimer(30, \React\Async\async(fn () => gc_collect_cycles())); + $this->loop->addPeriodicTimer(30, fn () => gc_collect_cycles()); // Register __invoke handler for this class to receive new connections... $socket->on('connection', $this);