<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedWorkersCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:workers'; }
    public function description(): string { return 'PPphp Distributed Workers'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Workers');
        $coordinator = \PpPhp\Core\Platform\Event\Distributed\DistributedRuntimeCoordinator::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); if ($coordinator->registry()->count() === 0) { $coordinator->registerWorker('distributed_console_worker', 'console_node', 1); } foreach ($coordinator->registry()->toArray() as $worker) { $this->line('- ' . $worker['nodeId'] . '/' . $worker['workerId'] . ' ' . $worker['status'] . ' capacity=' . $worker['capacity'] . ' active=' . $worker['activeJobs']); }
        return 0;
    }
}
