<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedQueuePartitionCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:queue:partition'; }
    public function description(): string { return 'PPphp Distributed Queue Partition'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Queue Partition');
        $manager = \PpPhp\Core\Platform\Event\Distributed\Queue\DistributedQueueCoordinator::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); if ($manager->registry()->get('console.queue') === null) { $manager->registerQueue('console.queue', 1); } $partition = $manager->assignPartition('console.queue', 'console_node', 'distributed_console_worker', 1); $this->line('Partition: ' . $partition->partitionId());
        return 0;
    }
}
