Files
proton/framework/Console/Commands/WorkerCommand.php
T
rsgrinko fce276bb13 Вебхуки: подписки, подпись посылок и доставка очередью
Общий HTTP-клиент с настройкой CA-бандла, на него же переведён драйвер mailer.
Воркер умеет несколько очередей: worker --queue=default,webhooks.
2026-09-13 00:21:59 +03:00

44 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace Rsgrinko\Proton\Console\Commands;
use Rsgrinko\Proton\Console\Command;
use Rsgrinko\Proton\Queue\Queue;
use Rsgrinko\Proton\Queue\Worker;
use Rsgrinko\Proton\Webhooks\Webhooks;
/**
* воркер очереди.
*/
final class WorkerCommand extends Command
{
public function name(): string
{
return 'worker';
}
public function description(): string
{
return 'разбирать очередь задач и вести расписание';
}
public function usage(): string
{
return 'worker [--once] [--queue=default,webhooks]';
}
public function run(): int
{
// Очередей можно перечислить несколько через запятую: задача из очереди
// слева берётся раньше
$queue = (string) $this->option('queue', Queue::DEFAULT_QUEUE . ',' . Webhooks::queue());
$result = (new Worker($queue))->run($this->hasOption('once'));
$this->line('Выполнено: ' . $result['done'] . ', с ошибкой: ' . $result['failed']);
return 0;
}
}