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:
20
app/src/Controller/API/External.php
Normal file
20
app/src/Controller/API/External.php
Normal 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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user