Skip to content
Snippets Groups Projects
Commit 2cfb6773 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Add a health check example

parent 9b2932c8
No related branches found
No related tags found
No related merge requests found
Pipeline #116677 passed
<?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];
}
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment