From b2da1cac2f15e00a12578a40bcce02630acb0e0c Mon Sep 17 00:00:00 2001 From: Supun Wimalasena Date: Wed, 11 Feb 2026 11:27:42 +0100 Subject: [PATCH] ping command and event --- bundle/src/Comms/Ping/PingCommand.php | 88 +++++++++++++++++++++++++++ bundle/src/Comms/Ping/PingEvent.php | 22 +++++++ 2 files changed, 110 insertions(+) create mode 100644 bundle/src/Comms/Ping/PingCommand.php create mode 100644 bundle/src/Comms/Ping/PingEvent.php diff --git a/bundle/src/Comms/Ping/PingCommand.php b/bundle/src/Comms/Ping/PingCommand.php new file mode 100644 index 0000000..9f92a25 --- /dev/null +++ b/bundle/src/Comms/Ping/PingCommand.php @@ -0,0 +1,88 @@ +section(); + $loadingSection->setMaxHeight(1); + + $tableSection = $output->section(); + $table = new Table($tableSection); + $table->setHeaders(['Component', 'URL', 'Status', 'Latency']); + $table->setStyle('box'); + $table->render(); + + foreach ($components as $c) { + + $loadingSection->writeln('Pinging ' . $c->value . '...'); + + $success = false; + $start = microtime(true); + + try { + $this->comms->send(new PingEvent(), $c); + $success = true; + } catch (CommsApiFailedException $e) {} + + $end = microtime(true); + $latency = round(($end - $start) * 1000); + + $table->appendRow( + [ + $c->value, + $this->instanceUrlResolver->privateUrlOf($c), + $success ? '✅' : '❌', + $latency . 'ms' + ] + ); + } + + $loadingSection->clear(); + $output->writeln(''); + + return Command::SUCCESS; + } + +} diff --git a/bundle/src/Comms/Ping/PingEvent.php b/bundle/src/Comms/Ping/PingEvent.php new file mode 100644 index 0000000..16718e7 --- /dev/null +++ b/bundle/src/Comms/Ping/PingEvent.php @@ -0,0 +1,22 @@ +