<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedFailoverClusterCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:cluster'; }
    public function description(): string { return 'PPphp Distributed Cluster Health'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Cluster Health');
        $summary = (new \PpPhp\Core\Platform\Event\Distributed\Failover\DistributedClusterHealthManager(\PpPhp\Core\Platform\Console\ConsolePath::basePath()))->summary(); $this->line('Workers: ' . (($summary['workers']['workers'] ?? 0))); $this->line('Leases: ' . (($summary['leases']['leases'] ?? 0))); $this->line('Queues: ' . (($summary['queues']['queues'] ?? 0))); $this->line('Assignments: ' . (($summary['scheduler']['assignments'] ?? 0))); $this->line('Status: OK');
        return 0;
    }
}
