<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class WorkerConsumeBatchCommand extends AbstractCommand
{
    public function name(): string { return 'worker:consume:batch'; }
    public function description(): string { return 'PPphp Queue Consume Batch'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Queue Consume Batch');
        $manager = \PpPhp\Core\Platform\Event\Consumer\QueueConsumerManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); for ($i = 1; $i <= 3; $i++) { $manager->consumer()->queue()->enqueue('consumer.console.batch.' . $i); } $batch = $manager->consumer()->consumeBatchResult(new \PpPhp\Core\Platform\Event\Consumer\Batch\QueueConsumerBatchOptions(10), static function (): void {}); $manager->save(); $this->line('Consumed: ' . $batch->acknowledged()); $this->line('Failed: ' . $batch->failed()); $this->line('Total: ' . $batch->total());
        return 0;
    }
}
