2026-05-02 01:05:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace PhpQml\Bridge\Controller;
|
|
|
|
|
|
2026-05-03 19:50:01 +02:00
|
|
|
use PhpQml\Bridge\PublisherInterface;
|
2026-05-02 01:05:19 +02:00
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Readiness probe used by the Qt host to detect when the backend is up.
|
|
|
|
|
* See PLAN.md §3 (*Startup*, step 4).
|
2026-05-03 13:19:58 +02:00
|
|
|
*
|
2026-05-03 19:50:01 +02:00
|
|
|
* `PublisherInterface` is injected purely as a deep-health canary: if the
|
|
|
|
|
* bridge bundle's autoload or container wiring is broken (e.g. a packaging
|
|
|
|
|
* build with a dangling vendor path-repo symlink), this controller can't
|
|
|
|
|
* even be constructed, so /healthz fails 500 instead of misleadingly
|
|
|
|
|
* returning 200 against a half-loaded bundle. The response includes the
|
|
|
|
|
* concrete class name so packagers can detect a wrong-implementation
|
|
|
|
|
* deployment from the canary value alone.
|
2026-05-02 01:05:19 +02:00
|
|
|
*/
|
|
|
|
|
final class HealthController
|
|
|
|
|
{
|
2026-05-03 13:19:58 +02:00
|
|
|
public function __construct(
|
2026-05-03 19:50:01 +02:00
|
|
|
private readonly PublisherInterface $publisher,
|
2026-05-03 13:19:58 +02:00
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-02 01:05:19 +02:00
|
|
|
#[Route('/healthz', name: 'php_qml_bridge_healthz', methods: ['GET'])]
|
|
|
|
|
public function __invoke(): JsonResponse
|
|
|
|
|
{
|
2026-05-03 13:19:58 +02:00
|
|
|
return new JsonResponse([
|
|
|
|
|
'status' => 'ok',
|
|
|
|
|
'bundle' => $this->publisher::class,
|
|
|
|
|
]);
|
2026-05-02 01:05:19 +02:00
|
|
|
}
|
|
|
|
|
}
|