diff --git a/src/HealthCheck/HealthCheck.php b/src/HealthCheck/HealthCheck.php new file mode 100644 index 0000000000000000000000000000000000000000..f45b9e00ba483fe4cc27cb0b1f6d6393bbcb2a69 --- /dev/null +++ b/src/HealthCheck/HealthCheck.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); + +namespace Dbp\Relay\ExampleBundle\HealthCheck; + +use Dbp\Relay\CoreBundle\HealthCheck\CheckInterface; +use Dbp\Relay\CoreBundle\HealthCheck\CheckOptions; +use Dbp\Relay\CoreBundle\HealthCheck\CheckResult; + +class HealthCheck implements CheckInterface +{ + public function getName(): string + { + return 'example'; + } + + public function check(CheckOptions $options): array + { + $ok = new CheckResult('Check that everything is OK'); + $ok->set(CheckResult::STATUS_SUCCESS, 'everything OK'); + + $failed = new CheckResult('Check something different'); + try { + throw new \RuntimeException('oh no'); + } catch (\Throwable $e) { + $failed->set(CheckResult::STATUS_FAILURE, $e->getMessage(), ['exception' => $e]); + } + + return [$ok, $failed]; + } +} diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index 3ed85194f647c8766c6b8658959400f339be2003..0632d74b7af41f1f049b2351cfff2fb1f49a9b11 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -22,6 +22,10 @@ services: autowire: true autoconfigure: true + Dbp\Relay\ExampleBundle\HealthCheck\HealthCheck: + autowire: true + autoconfigure: true + Dbp\Relay\ExampleBundle\Service\MyCustomService: autowire: true autoconfigure: true