Wire HealthCheckService in container
This commit is contained in:
@@ -8,6 +8,7 @@ use Instana\RobotShop\Ratings\Controller\HealthController;
|
||||
use Instana\RobotShop\Ratings\Controller\RatingsApiController;
|
||||
use Instana\RobotShop\Ratings\Integration\InstanaHeadersLoggingProcessor;
|
||||
use Instana\RobotShop\Ratings\Service\CatalogueService;
|
||||
use Instana\RobotShop\Ratings\Service\HealthCheckService;
|
||||
use Instana\RobotShop\Ratings\Service\RatingsService;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
@@ -96,6 +97,11 @@ class Kernel extends BaseKernel implements EventSubscriberInterface
|
||||
->addMethodCall('setLogger', [new Reference('logger')])
|
||||
->setAutowired(true);
|
||||
|
||||
$c->register(HealthCheckService::class)
|
||||
->addArgument(new Reference('database.connection'))
|
||||
->addMethodCall('setLogger', [new Reference('logger')])
|
||||
->setAutowired(true);
|
||||
|
||||
$c->register('database.connection', \PDO::class)
|
||||
->setFactory([new Reference(Database::class), 'getConnection']);
|
||||
|
||||
|
@@ -5,9 +5,13 @@ declare(strict_types=1);
|
||||
namespace Instana\RobotShop\Ratings\Service;
|
||||
|
||||
use PDO;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
|
||||
class HealthCheckService
|
||||
class HealthCheckService implements LoggerAwareInterface
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
|
||||
/**
|
||||
* @var PDO
|
||||
*/
|
||||
@@ -18,7 +22,7 @@ class HealthCheckService
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function checkConnectivity()
|
||||
public function checkConnectivity(): bool
|
||||
{
|
||||
return $this->pdo->prepare('SELECT 1 + 1 FROM DUAL;')->execute();
|
||||
}
|
||||
|
Reference in New Issue
Block a user