feat(scraping): implémenter le health check de tous les scrapers
- Commande CheckAllScrapersHealth + handler avec ports dédiés - Value Object ContentSourceHealthCheckData - Resource API Platform et State Processor - Adapters InMemory et tests unitaires + fonctionnels
This commit is contained in:
parent
734dea569c
commit
ae7a485195
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Domain\Scraping\Adapter;
|
||||
|
||||
use App\Domain\Scraping\Domain\Contract\Repository\ContentSourceHealthRepositoryInterface;
|
||||
|
||||
class InMemoryContentSourceHealthRepository implements ContentSourceHealthRepositoryInterface
|
||||
{
|
||||
/** @var array<int, array{status: string, testedAt: ?\DateTimeImmutable, error: ?string}> */
|
||||
private array $statuses = [];
|
||||
|
||||
public function markAsTesting(int $sourceId): void
|
||||
{
|
||||
$this->statuses[$sourceId] = ['status' => 'testing', 'testedAt' => null, 'error' => null];
|
||||
}
|
||||
|
||||
public function markAsHealthy(int $sourceId, \DateTimeImmutable $testedAt): void
|
||||
{
|
||||
$this->statuses[$sourceId] = ['status' => 'ok', 'testedAt' => $testedAt, 'error' => null];
|
||||
}
|
||||
|
||||
public function markAsUnhealthy(int $sourceId, \DateTimeImmutable $testedAt, string $error): void
|
||||
{
|
||||
$this->statuses[$sourceId] = ['status' => 'ko', 'testedAt' => $testedAt, 'error' => $error];
|
||||
}
|
||||
|
||||
public function getStatus(int $sourceId): ?string
|
||||
{
|
||||
return $this->statuses[$sourceId]['status'] ?? null;
|
||||
}
|
||||
|
||||
public function getError(int $sourceId): ?string
|
||||
{
|
||||
return $this->statuses[$sourceId]['error'] ?? null;
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->statuses = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user