From fb995f2bea7f8cc34f4b0de2f36c6c8bf5a029bb Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 3 Jul 2025 10:10:06 +0200 Subject: [PATCH] Allow individual real-time updates topics to be enabled --- module/Core/config/dependencies.config.php | 1 + .../Core/config/event_dispatcher.config.php | 6 +++ module/Core/functions/functions.php | 16 ++++++++ module/Core/src/Config/EnvVars.php | 1 + .../Config/Options/RealTimeUpdatesOptions.php | 39 +++++++++++++++++++ .../AbstractNotifyNewShortUrlListener.php | 7 ++++ .../Async/AbstractNotifyVisitListener.php | 20 +++++++--- .../RabbitMq/NotifyNewShortUrlToRabbitMq.php | 4 +- .../RabbitMq/NotifyVisitToRabbitMq.php | 4 +- .../RedisPubSub/NotifyNewShortUrlToRedis.php | 4 +- .../RedisPubSub/NotifyVisitToRedis.php | 4 +- module/Core/src/EventDispatcher/Topic.php | 9 ++++- .../NotifyNewShortUrlToMercureTest.php | 2 + .../Mercure/NotifyVisitToMercureTest.php | 9 ++++- .../NotifyNewShortUrlToRabbitMqTest.php | 2 + .../RabbitMq/NotifyVisitToRabbitMqTest.php | 2 + .../NotifyNewShortUrlToRedisTest.php | 10 ++++- .../RedisPubSub/NotifyVisitToRedisTest.php | 10 ++++- 18 files changed, 137 insertions(+), 13 deletions(-) create mode 100644 module/Core/src/Config/Options/RealTimeUpdatesOptions.php diff --git a/module/Core/config/dependencies.config.php b/module/Core/config/dependencies.config.php index 1cd1e961..75c70594 100644 --- a/module/Core/config/dependencies.config.php +++ b/module/Core/config/dependencies.config.php @@ -36,6 +36,7 @@ return [ Config\Options\QrCodeOptions::class => [Config\Options\QrCodeOptions::class, 'fromEnv'], Config\Options\RabbitMqOptions::class => [Config\Options\RabbitMqOptions::class, 'fromEnv'], Config\Options\RobotsOptions::class => [Config\Options\RobotsOptions::class, 'fromEnv'], + Config\Options\RealTimeUpdatesOptions::class => [Config\Options\RealTimeUpdatesOptions::class, 'fromEnv'], RedirectRule\ShortUrlRedirectRuleService::class => ConfigAbstractFactory::class, RedirectRule\ShortUrlRedirectionResolver::class => ConfigAbstractFactory::class, diff --git a/module/Core/config/event_dispatcher.config.php b/module/Core/config/event_dispatcher.config.php index d146a516..b5db4b85 100644 --- a/module/Core/config/event_dispatcher.config.php +++ b/module/Core/config/event_dispatcher.config.php @@ -110,18 +110,21 @@ return (static function (): array { EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', + Config\Options\RealTimeUpdatesOptions::class, ], EventDispatcher\Mercure\NotifyNewShortUrlToMercure::class => [ MercureHubPublishingHelper::class, EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', + Config\Options\RealTimeUpdatesOptions::class, ], EventDispatcher\RabbitMq\NotifyVisitToRabbitMq::class => [ RabbitMqPublishingHelper::class, EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', + Config\Options\RealTimeUpdatesOptions::class, Config\Options\RabbitMqOptions::class, ], EventDispatcher\RabbitMq\NotifyNewShortUrlToRabbitMq::class => [ @@ -129,6 +132,7 @@ return (static function (): array { EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', + Config\Options\RealTimeUpdatesOptions::class, Config\Options\RabbitMqOptions::class, ], EventDispatcher\RedisPubSub\NotifyVisitToRedis::class => [ @@ -136,6 +140,7 @@ return (static function (): array { EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', + Config\Options\RealTimeUpdatesOptions::class, 'config.redis.pub_sub_enabled', ], EventDispatcher\RedisPubSub\NotifyNewShortUrlToRedis::class => [ @@ -143,6 +148,7 @@ return (static function (): array { EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', + Config\Options\RealTimeUpdatesOptions::class, 'config.redis.pub_sub_enabled', ], diff --git a/module/Core/functions/functions.php b/module/Core/functions/functions.php index 513e885d..a4126a13 100644 --- a/module/Core/functions/functions.php +++ b/module/Core/functions/functions.php @@ -266,6 +266,22 @@ function enumValues(string $enum): array ); } +/** + * @param class-string $enum + * @return string[] + */ +function enumNames(string $enum): array +{ + static $cache; + if ($cache === null) { + $cache = []; + } + + return $cache[$enum] ?? ( + $cache[$enum] = array_map(static fn (BackedEnum $type) => (string) $type->name, $enum::cases()) + ); +} + /** * @param class-string $enum */ diff --git a/module/Core/src/Config/EnvVars.php b/module/Core/src/Config/EnvVars.php index 1f6f2c03..7fa1a95b 100644 --- a/module/Core/src/Config/EnvVars.php +++ b/module/Core/src/Config/EnvVars.php @@ -85,6 +85,7 @@ enum EnvVars: string case MEMORY_LIMIT = 'MEMORY_LIMIT'; case INITIAL_API_KEY = 'INITIAL_API_KEY'; case SKIP_INITIAL_GEOLITE_DOWNLOAD = 'SKIP_INITIAL_GEOLITE_DOWNLOAD'; + case REAL_TIME_UPDATES_TOPICS = 'REAL_TIME_UPDATES_TOPICS'; /** @deprecated Use REDIRECT_EXTRA_PATH */ case REDIRECT_APPEND_EXTRA_PATH = 'REDIRECT_APPEND_EXTRA_PATH'; diff --git a/module/Core/src/Config/Options/RealTimeUpdatesOptions.php b/module/Core/src/Config/Options/RealTimeUpdatesOptions.php new file mode 100644 index 00000000..35717593 --- /dev/null +++ b/module/Core/src/Config/Options/RealTimeUpdatesOptions.php @@ -0,0 +1,39 @@ +enabledTopics = $enabledTopics ?? Topic::allTopicNames(); + } + + public static function fromEnv(): self + { + $enabledTopics = splitByComma(EnvVars::REAL_TIME_UPDATES_TOPICS->loadFromEnv()); + + return new self( + enabledTopics: count($enabledTopics) === 0 + ? Topic::allTopicNames() + // TODO Validate provided topics are in fact Topic names + : splitByComma(EnvVars::REAL_TIME_UPDATES_TOPICS->loadFromEnv()), + ); + } + + public function isTopicEnabled(Topic $topic): bool + { + return contains($topic->name, $this->enabledTopics); + } +} diff --git a/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php b/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php index 1aa2235d..aced04f0 100644 --- a/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php +++ b/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php @@ -7,8 +7,10 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\Async; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; +use Shlinkio\Shlink\Core\EventDispatcher\Topic; use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl; use Throwable; @@ -19,6 +21,7 @@ abstract class AbstractNotifyNewShortUrlListener extends AbstractAsyncListener private readonly PublishingUpdatesGeneratorInterface $updatesGenerator, private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, + private readonly RealTimeUpdatesOptions $realTimeUpdatesOptions, ) { } @@ -40,6 +43,10 @@ abstract class AbstractNotifyNewShortUrlListener extends AbstractAsyncListener return; } + if (! $this->realTimeUpdatesOptions->isTopicEnabled(Topic::NEW_SHORT_URL)) { + return; + } + try { $this->publishingHelper->publishUpdate($this->updatesGenerator->newShortUrlUpdate($shortUrl)); } catch (Throwable $e) { diff --git a/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php b/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php index e871588f..affe4f32 100644 --- a/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php +++ b/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php @@ -8,8 +8,10 @@ use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\UrlVisited; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; +use Shlinkio\Shlink\Core\EventDispatcher\Topic; use Shlinkio\Shlink\Core\Visit\Entity\Visit; use Throwable; @@ -22,6 +24,7 @@ abstract class AbstractNotifyVisitListener extends AbstractAsyncListener private readonly PublishingUpdatesGeneratorInterface $updatesGenerator, private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, + private readonly RealTimeUpdatesOptions $realTimeUpdatesOptions, ) { } @@ -61,12 +64,19 @@ abstract class AbstractNotifyVisitListener extends AbstractAsyncListener protected function determineUpdatesForVisit(Visit $visit): array { if ($visit->isOrphan()) { - return [$this->updatesGenerator->newOrphanVisitUpdate($visit)]; + return $this->realTimeUpdatesOptions->isTopicEnabled(Topic::NEW_ORPHAN_VISIT) + ? [$this->updatesGenerator->newOrphanVisitUpdate($visit)] + : []; } - return [ - $this->updatesGenerator->newShortUrlVisitUpdate($visit), - $this->updatesGenerator->newVisitUpdate($visit), - ]; + $topics = []; + if ($this->realTimeUpdatesOptions->isTopicEnabled(Topic::NEW_SHORT_URL_VISIT)) { + $topics[] = $this->updatesGenerator->newShortUrlVisitUpdate($visit); + } + if ($this->realTimeUpdatesOptions->isTopicEnabled(Topic::NEW_VISIT)) { + $topics[] = $this->updatesGenerator->newVisitUpdate($visit); + } + + return $topics; } } diff --git a/module/Core/src/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMq.php b/module/Core/src/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMq.php index b8c18fb6..ef63b1e4 100644 --- a/module/Core/src/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMq.php +++ b/module/Core/src/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMq.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Core\Config\Options\RabbitMqOptions; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener; use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; @@ -19,9 +20,10 @@ class NotifyNewShortUrlToRabbitMq extends AbstractNotifyNewShortUrlListener PublishingUpdatesGeneratorInterface $updatesGenerator, EntityManagerInterface $em, LoggerInterface $logger, + RealTimeUpdatesOptions $realTimeUpdatesOptions, private readonly RabbitMqOptions $options, ) { - parent::__construct($rabbitMqHelper, $updatesGenerator, $em, $logger); + parent::__construct($rabbitMqHelper, $updatesGenerator, $em, $logger, $realTimeUpdatesOptions); } protected function isEnabled(): bool diff --git a/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php b/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php index bb55f169..0bab0739 100644 --- a/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php +++ b/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Core\Config\Options\RabbitMqOptions; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener; use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; @@ -19,9 +20,10 @@ class NotifyVisitToRabbitMq extends AbstractNotifyVisitListener PublishingUpdatesGeneratorInterface $updatesGenerator, EntityManagerInterface $em, LoggerInterface $logger, + RealTimeUpdatesOptions $realTimeUpdatesOptions, private readonly RabbitMqOptions $options, ) { - parent::__construct($rabbitMqHelper, $updatesGenerator, $em, $logger); + parent::__construct($rabbitMqHelper, $updatesGenerator, $em, $logger, $realTimeUpdatesOptions); } protected function isEnabled(): bool diff --git a/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php b/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php index 5cee9d5e..62b4e291 100644 --- a/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php +++ b/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php @@ -7,6 +7,7 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener; use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; @@ -18,9 +19,10 @@ class NotifyNewShortUrlToRedis extends AbstractNotifyNewShortUrlListener PublishingUpdatesGeneratorInterface $updatesGenerator, EntityManagerInterface $em, LoggerInterface $logger, + RealTimeUpdatesOptions $realTimeUpdatesOptions, private readonly bool $enabled, ) { - parent::__construct($redisHelper, $updatesGenerator, $em, $logger); + parent::__construct($redisHelper, $updatesGenerator, $em, $logger, $realTimeUpdatesOptions); } protected function isEnabled(): bool diff --git a/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php b/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php index ae349495..1d4dc5be 100644 --- a/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php +++ b/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php @@ -7,6 +7,7 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener; use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; @@ -18,9 +19,10 @@ class NotifyVisitToRedis extends AbstractNotifyVisitListener PublishingUpdatesGeneratorInterface $updatesGenerator, EntityManagerInterface $em, LoggerInterface $logger, + RealTimeUpdatesOptions $realTimeUpdatesOptions, private readonly bool $enabled, ) { - parent::__construct($redisHelper, $updatesGenerator, $em, $logger); + parent::__construct($redisHelper, $updatesGenerator, $em, $logger, $realTimeUpdatesOptions); } protected function isEnabled(): bool diff --git a/module/Core/src/EventDispatcher/Topic.php b/module/Core/src/EventDispatcher/Topic.php index 8c7a7d45..9f018bb3 100644 --- a/module/Core/src/EventDispatcher/Topic.php +++ b/module/Core/src/EventDispatcher/Topic.php @@ -4,16 +4,23 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core\EventDispatcher; +use function Shlinkio\Shlink\Core\enumNames; use function sprintf; enum Topic: string { case NEW_VISIT = 'https://shlink.io/new-visit'; + case NEW_SHORT_URL_VISIT = 'https://shlink.io/new-visit/%s'; case NEW_ORPHAN_VISIT = 'https://shlink.io/new-orphan-visit'; case NEW_SHORT_URL = 'https://shlink.io/new-short-url'; public static function newShortUrlVisit(string|null $shortCode): string { - return sprintf('%s/%s', self::NEW_VISIT->value, $shortCode ?? ''); + return sprintf(self::NEW_SHORT_URL_VISIT->value, $shortCode ?? ''); + } + + public static function allTopicNames(): array + { + return enumNames(self::class); } } diff --git a/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php b/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php index 20d6830d..c6b67727 100644 --- a/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php +++ b/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php @@ -12,6 +12,7 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated; use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyNewShortUrlToMercure; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; @@ -37,6 +38,7 @@ class NotifyNewShortUrlToMercureTest extends TestCase $this->updatesGenerator, $this->em, $this->logger, + new RealTimeUpdatesOptions(), ); } diff --git a/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php b/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php index 91569c9b..b362c1a5 100644 --- a/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php +++ b/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php @@ -13,6 +13,7 @@ use Psr\Log\LoggerInterface; use RuntimeException; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\UrlVisited; use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyVisitToMercure; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; @@ -36,7 +37,13 @@ class NotifyVisitToMercureTest extends TestCase $this->em = $this->createMock(EntityManagerInterface::class); $this->logger = $this->createMock(LoggerInterface::class); - $this->listener = new NotifyVisitToMercure($this->helper, $this->updatesGenerator, $this->em, $this->logger); + $this->listener = new NotifyVisitToMercure( + $this->helper, + $this->updatesGenerator, + $this->em, + $this->logger, + new RealTimeUpdatesOptions(), + ); } #[Test] diff --git a/module/Core/test/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMqTest.php b/module/Core/test/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMqTest.php index b0c5a0e0..e4351c36 100644 --- a/module/Core/test/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMqTest.php +++ b/module/Core/test/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMqTest.php @@ -16,6 +16,7 @@ use RuntimeException; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Config\Options\RabbitMqOptions; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Shlinkio\Shlink\Core\EventDispatcher\RabbitMq\NotifyNewShortUrlToRabbitMq; @@ -115,6 +116,7 @@ class NotifyNewShortUrlToRabbitMqTest extends TestCase $this->updatesGenerator, $this->em, $this->logger, + new RealTimeUpdatesOptions(), new RabbitMqOptions($enabled), ); } diff --git a/module/Core/test/EventDispatcher/RabbitMq/NotifyVisitToRabbitMqTest.php b/module/Core/test/EventDispatcher/RabbitMq/NotifyVisitToRabbitMqTest.php index 8af719b3..78abb5c7 100644 --- a/module/Core/test/EventDispatcher/RabbitMq/NotifyVisitToRabbitMqTest.php +++ b/module/Core/test/EventDispatcher/RabbitMq/NotifyVisitToRabbitMqTest.php @@ -17,6 +17,7 @@ use RuntimeException; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Config\Options\RabbitMqOptions; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\UrlVisited; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Shlinkio\Shlink\Core\EventDispatcher\RabbitMq\NotifyVisitToRabbitMq; @@ -189,6 +190,7 @@ class NotifyVisitToRabbitMqTest extends TestCase $this->updatesGenerator, $this->em, $this->logger, + new RealTimeUpdatesOptions(), $options ?? new RabbitMqOptions(enabled: true), ); } diff --git a/module/Core/test/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedisTest.php b/module/Core/test/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedisTest.php index abbe23b9..412f603e 100644 --- a/module/Core/test/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedisTest.php +++ b/module/Core/test/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedisTest.php @@ -15,6 +15,7 @@ use Psr\Log\LoggerInterface; use RuntimeException; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub\NotifyNewShortUrlToRedis; @@ -77,6 +78,13 @@ class NotifyNewShortUrlToRedisTest extends TestCase private function createListener(bool $enabled = true): NotifyNewShortUrlToRedis { - return new NotifyNewShortUrlToRedis($this->helper, $this->updatesGenerator, $this->em, $this->logger, $enabled); + return new NotifyNewShortUrlToRedis( + $this->helper, + $this->updatesGenerator, + $this->em, + $this->logger, + new RealTimeUpdatesOptions(), + $enabled, + ); } } diff --git a/module/Core/test/EventDispatcher/RedisPubSub/NotifyVisitToRedisTest.php b/module/Core/test/EventDispatcher/RedisPubSub/NotifyVisitToRedisTest.php index 7cbf68b6..d14ab631 100644 --- a/module/Core/test/EventDispatcher/RedisPubSub/NotifyVisitToRedisTest.php +++ b/module/Core/test/EventDispatcher/RedisPubSub/NotifyVisitToRedisTest.php @@ -15,6 +15,7 @@ use Psr\Log\LoggerInterface; use RuntimeException; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; +use Shlinkio\Shlink\Core\Config\Options\RealTimeUpdatesOptions; use Shlinkio\Shlink\Core\EventDispatcher\Event\UrlVisited; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub\NotifyVisitToRedis; @@ -76,6 +77,13 @@ class NotifyVisitToRedisTest extends TestCase private function createListener(bool $enabled = true): NotifyVisitToRedis { - return new NotifyVisitToRedis($this->helper, $this->updatesGenerator, $this->em, $this->logger, $enabled); + return new NotifyVisitToRedis( + $this->helper, + $this->updatesGenerator, + $this->em, + $this->logger, + new RealTimeUpdatesOptions(), + $enabled, + ); } }