<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedLeaseAcquireCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:lease:acquire'; }
    public function description(): string { return 'PPphp Distributed Lease Acquire'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Lease Acquire');
        $manager = \PpPhp\Core\Platform\Event\Distributed\Lease\DistributedLeaseManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $lease = $manager->acquire('console_job', 'console_node', 'distributed_console_worker', 60); $this->line('Acquired: ' . ($lease !== null ? 'YES' : 'NO')); if ($lease !== null) { $this->line('Lease: ' . $lease->leaseId()); }
        return 0;
    }
}
