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,20 @@
<?php
namespace Incoviba\Controller\API;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Ideal;
use Incoviba\Service;
class External extends Ideal\Controller
{
use withJson;
public function check(ServerRequestInterface $request, ResponseInterface $response, Service\External $externalService): ResponseInterface
{
if ($externalService->check()) {
return $response->withStatus(204);
}
return $response->withStatus(409);
}
}

View File

@ -4,13 +4,15 @@ namespace Incoviba\Controller\API;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Incoviba\Common\Ideal;
use Incoviba\Exception\ServiceAction\Read;
use Incoviba\Service;
class Queues extends Ideal\Controller
{
use withJson;
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Service\Queue $queueService): ResponseInterface
public function __invoke(ServerRequestInterface $request, ResponseInterface $response,
Service\Queue $queueService): ResponseInterface
{
$output = [
'success' => false
@ -20,4 +22,20 @@ class Queues extends Ideal\Controller
}
return $this->withJson($response, $output);
}
public function jobs(ServerRequestInterface $request, ResponseInterface $response,
Service\Queue $queueService): ResponseInterface
{
$output = [
'jobs' => array_column($queueService->getPendingJobs(), 'id')
];
return $this->withJson($response, $output);
}
public function run(ServerRequestInterface $request, ResponseInterface $response, Service\Queue $queueService,
int $job_id): ResponseInterface
{
if ($queueService->runJob($job_id, $request)) {
return $response->withStatus(200);
}
return $response->withStatus(422);
}
}