Move all provider-related classes, enums, interface and trait into App\Service\Provider; move SvgRenderer into App\Service\Renderer. ContributionAggregator stays at the Service root as the orchestrator. Test namespaces and use statements updated to match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
974 B
PHP
40 lines
974 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Provider;
|
|
|
|
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
|
|
|
final class ProviderHealthChecker
|
|
{
|
|
public function __construct(
|
|
#[AutowireIterator('app.provider')]
|
|
private readonly iterable $providers,
|
|
) {}
|
|
|
|
/**
|
|
* @return array{status: string, providers: array<string, array<string, string>>}
|
|
*/
|
|
public function check(): array
|
|
{
|
|
$statuses = [];
|
|
$hasError = false;
|
|
|
|
/** @var ProviderInterface $provider */
|
|
foreach ($this->providers as $provider) {
|
|
$status = $provider->probe();
|
|
$statuses[$status->name] = $status->toArray();
|
|
|
|
if ($status->status === ProviderStatusType::Error) {
|
|
$hasError = true;
|
|
}
|
|
}
|
|
|
|
return [
|
|
'status' => $hasError ? 'degraded' : 'ok',
|
|
'providers' => $statuses,
|
|
];
|
|
}
|
|
}
|