[#FER-19] Ajouter le healthCheck du pont bascule (!58)
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #58 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #58.
This commit is contained in:
32
src/State/PontBasculeHealthProvider.php
Normal file
32
src/State/PontBasculeHealthProvider.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\ApiResource\PontBasculeHealthCheck;
|
||||
use App\Service\PontBasculeService;
|
||||
|
||||
final readonly class PontBasculeHealthProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private PontBasculeService $pontBasculeService,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): PontBasculeHealthCheck
|
||||
{
|
||||
$health = $this->pontBasculeService->checkHealth();
|
||||
|
||||
$resource = new PontBasculeHealthCheck();
|
||||
$resource->healthy = $health->isHealthy();
|
||||
$resource->ok = $health->isOk();
|
||||
$resource->busy = $health->isBusy();
|
||||
$resource->portConnected = $health->isPortConnected();
|
||||
$resource->portError = $health->getPortError();
|
||||
$resource->hostname = $health->getHostname();
|
||||
|
||||
return $resource;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user