Weitere Checks programmieren
Mit ein wenig Programmierkenntnissen hast du auch die Möglichkeit, bisher nicht unterstützte Health Checks für andere Funktionen durchführen zu lassen. Beispielsweise die Anbindung von Redis.
Datenbank Beispiel
<?php declare(strict_types=1);
namespace ShopStudio\HealthCheck\Core\HealthCheck;
use Doctrine\DBAL\Connection;
class DatabaseHealthCheck implements HealthCheckInterface
{
public const NAME = 'database';
private Connection $connection;
public function __construct(Connection $connection)
{
$this->connection = $connection;
}
public function getName(): string
{
return self::NAME;
}
public function check(): ?HealthCheckResult
{
$up = true;
try {
$this->connection->executeQuery($this->connection->getDatabasePlatform()->getDummySelectSQL());
} catch (\Throwable $throwable) {
$up = false;
}
return new HealthCheckResult($up, ['additional' => 'payload']);
}
}
Last updated
Was this helpful?