<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedFailoverNodesCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:failover:nodes'; }
    public function description(): string { return 'PPphp Distributed Failover Nodes'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Failover Nodes');
        $summary = \PpPhp\Core\Platform\Event\Distributed\Failover\DistributedFailoverManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath())->summary(); foreach ($summary['nodes'] as $node) { $this->line('- ' . $node['nodeId'] . ' ' . $node['status'] . ' failed=' . ($node['failed'] ? 'YES' : 'NO') . ' reason=' . $node['reason']); }
        return 0;
    }
}
