<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class WorkerHealthListCommand extends AbstractCommand
{
    public function name(): string { return 'worker:health:list'; }
    public function description(): string { return 'PPphp Worker Health List'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Worker Health List');
        $health = \PpPhp\Core\Platform\Event\Worker\Monitoring\WorkerHealthManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $summary = $health->summary(); foreach ($summary['records'] as $record) { $this->line('- ' . $record['workerId'] . ' ' . $record['status']['state'] . ' healthy=' . ($record['status']['healthy'] ? 'YES' : 'NO') . ' reason=' . $record['status']['reason']); }
        return 0;
    }
}
