diff --git a/app/src/Service/Queue.php b/app/src/Service/Queue.php index f22f06b..b704b9c 100644 --- a/app/src/Service/Queue.php +++ b/app/src/Service/Queue.php @@ -2,6 +2,7 @@ namespace Incoviba\Service; use Exception; +use Psr\Http\Message\RequestInterface; use Psr\Log\LoggerInterface; use Incoviba\Common\Ideal; use Incoviba\Exception\ServiceAction\{Create, Read}; @@ -34,7 +35,7 @@ class Queue extends Ideal\Service } } - public function run(): bool + public function run(?RequestInterface $request): bool { try { $jobs = $this->jobService->getPending(); @@ -55,20 +56,24 @@ class Queue extends Ideal\Service } $worker = $this->workers[$type]; + if (is_a($worker, Service\Worker\Request::class)) { + $worker->setRequest($request); + } try { if (!$worker->execute($job)) { $errors []= $job->id; - } else { - if (!$this->jobService->execute($job)) { - $errors []= $job->id; - } + continue; + } + if (!$this->jobService->execute($job)) { + $errors []= $job->id; } } catch (Exception $exception) { $final = new Exception("Could not run job", 0, $exception); $this->logger->warning($final); $errors []= $job->id; } + break; } return count($errors) === 0; }