From 0f0c81e283d71cb56fe4faf8f863bcb39d3738e4 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Tue, 13 May 2025 20:18:40 -0400 Subject: [PATCH] Uso de request en queue --- app/src/Service/Queue.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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; }