refs #1555. Changes eventListener Mercure
testing/ogcore-api/pipeline/head This commit looks good Details

pull/21/head
Manuel Aranda Rosales 2025-02-25 08:48:53 +01:00
parent d881c763cf
commit a00dc7a59f
2 changed files with 28 additions and 1 deletions

View File

@ -24,6 +24,19 @@ class ClientStatusNotifier
}
public function postUpdate(Client $client, PostUpdateEventArgs $event): void
{
try {
$this->notifyClientStatusChange($client);
} catch (\Exception $e) {
$this->logger->error('Error al notificar el cambio de estado de un cliente: ', [
'client' => $client->getUuid(),
'status' => $client->getStatus(),
'error' => $e->getMessage(),
]);
}
}
private function notifyClientStatusChange(Client $client): void
{
$update = new Update(
'clients',

View File

@ -25,10 +25,24 @@ class TraceStatusProgressNotifier
}
public function postUpdate(Trace $trace, PostUpdateEventArgs $event): void
{
try {
$this->notifyTraceStatusProgressChange($trace);
} catch (\Exception $e) {
$this->logger->error('Error al notificar el cambio de estado de una traza/log: ', [
'client' => $trace->getUuid(),
'status' => $trace->getStatus(),
'progress' => $trace->getProgress(),
'error' => $e->getMessage(),
]);
}
}
private function notifyTraceStatusProgressChange(Trace $trace): void
{
$update = new Update(
'traces',
json_encode(['@id' => '/traces/'.$trace->getUuid(), 'status' => $trace->getStatus(), 'progress' => $trace->getProgress() / 100])
json_encode(['@id' => '/traces/' . $trace->getUuid(), 'status' => $trace->getStatus(), 'progress' => $trace->getProgress() / 100])
);
$this->hub->publish($update);