--keep-jobs option added for 'point:update:websocket-messages' command.
This commit is contained in:
parent
05aaa1d4e1
commit
4707b41f27
|
@ -9,6 +9,7 @@ use Skobkin\Bundle\PointToolsBundle\DTO\Api\WebSocket\Message;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\WebSocket\WebSocketMessageProcessor;
|
use Skobkin\Bundle\PointToolsBundle\Service\WebSocket\WebSocketMessageProcessor;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,12 +50,15 @@ class ProcessWebsocketUpdatesCommand extends Command
|
||||||
$this
|
$this
|
||||||
->setName('point:update:websocket-messages')
|
->setName('point:update:websocket-messages')
|
||||||
->setDescription('Reads and processes updates from Beanstalkd queue pipe')
|
->setDescription('Reads and processes updates from Beanstalkd queue pipe')
|
||||||
|
->addOption('keep-jobs', 'k', InputOption::VALUE_NONE, 'Don\'t delete jobs from queue after processing')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$keepJobs = (bool) $input->getOption('keep-jobs');
|
||||||
|
|
||||||
/** @var Job $job */
|
/** @var Job $job */
|
||||||
while ($job = $this->bsClient->reserveFromTube($this->bsTubeName, 0)) {
|
while ($job = $this->bsClient->reserveFromTube($this->bsTubeName, 0)) {
|
||||||
try {
|
try {
|
||||||
|
@ -69,8 +73,14 @@ class ProcessWebsocketUpdatesCommand extends Command
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$output->writeln('Processing job #'.$job->getId());
|
||||||
|
|
||||||
if ($this->messageProcessor->processMessage($message)) {
|
if ($this->messageProcessor->processMessage($message)) {
|
||||||
// BS delete item
|
if ($keepJobs) {
|
||||||
|
$this->bsClient->release($job);
|
||||||
|
} else {
|
||||||
|
$this->bsClient->delete($job);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// BS return to queue
|
// BS return to queue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue