Cambio en queue para que no quede pegado esperando respuesta en cli.

Chequeo de servicios externos para agregar elementos pendientes.
This commit is contained in:
Juan Pablo Vial
2025-05-15 19:32:25 -04:00
parent 8d32aecd09
commit 8965354528
21 changed files with 687 additions and 65 deletions

View File

@ -0,0 +1,46 @@
<?php
namespace Incoviba\Service\Worker;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal;
use Incoviba\Model;
use Incoviba\Service;
class CheckExternal extends Ideal\Service implements Service\Worker
{
public function __construct(LoggerInterface $logger, protected ContainerInterface $container)
{
parent::__construct($logger);
}
protected Service\Queue $queueService;
public function execute(Model\Job $job): bool
{
$configuration = $job->configuration;
$serviceClass = $configuration['service'];
if (!$this->container->has($serviceClass)) {
return false;
}
try {
$service = $this->container->get($serviceClass);
} catch (NotFoundExceptionInterface | ContainerExceptionInterface) {
return false;
}
$method = $configuration['method'] ?? 'check';
if (!method_exists($service, $method)) {
return false;
}
if (!isset($this->queueService)) {
$this->queueService = $this->container->get(Service\Queue::class);
}
$queues = $service->{$method}();
foreach ($queues as $queue) {
$this->queueService->enqueue($queue);
}
return true;
}
}