This commit is contained in:
team3
2026-06-03 22:05:20 +02:00
parent d7e8df6876
commit 40de56c27b
5119 changed files with 552560 additions and 24 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace App\MessageHandler;
use App\Message\TriggerPriceImport;
use App\Service\Prices\RedisImportService;
use Psr\Log\LoggerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Stopwatch\Stopwatch;
use Throwable;
#[AsMessageHandler]
final readonly class TriggerPriceImportHandler
{
public function __construct(
private RedisImportService $importService,
private LoggerInterface $logger,
private readonly Stopwatch $stopwatch
) {}
public function __invoke(TriggerPriceImport $message): void
{
$ts = $message->timestamp ?? 'undefined';
$this->stopwatch->start('price_import_trigger');
print('[Handler] Start Import with client timestamp: '.$ts."\n");
try {
$this->importService->writePrices();
} catch (Throwable $exception) {
$this->logger->error('[Handler] Import error: ', [
'timestamp' => $ts,
'message' => $exception->getMessage(),
'exception' => $exception,
]);
print('[Handler] Import error: '.$exception->getMessage()."\n");
throw $exception;
}
$event = $this->stopwatch->stop('price_import_trigger');
$duration = number_format(($event?->getDuration() ?? 0) / 1000, 2);
print('[Handler] Import complete with client timestamp: '.$ts."\n");
print('[Handler] Duration: '.$duration." s\n\n");
}
}