diff --git a/module/Core/src/EventDispatcher/Async/AbstractAsyncListener.php b/module/Core/src/EventDispatcher/Async/AbstractAsyncListener.php index e9c78306..ae8391db 100644 --- a/module/Core/src/EventDispatcher/Async/AbstractAsyncListener.php +++ b/module/Core/src/EventDispatcher/Async/AbstractAsyncListener.php @@ -8,5 +8,5 @@ abstract class AbstractAsyncListener { abstract protected function isEnabled(): bool; - abstract protected function getRemoteSystemName(): string; + abstract protected function getRemoteSystem(): RemoteSystem; } diff --git a/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php b/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php index eab93209..ab435577 100644 --- a/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php +++ b/module/Core/src/EventDispatcher/Async/AbstractNotifyNewShortUrlListener.php @@ -30,7 +30,7 @@ abstract class AbstractNotifyNewShortUrlListener extends AbstractAsyncListener $shortUrlId = $shortUrlCreated->shortUrlId; $shortUrl = $this->em->find(ShortUrl::class, $shortUrlId); - $name = $this->getRemoteSystemName(); + $name = $this->getRemoteSystem()->value; if ($shortUrl === null) { $this->logger->warning( diff --git a/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php b/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php index a2967e64..5852b032 100644 --- a/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php +++ b/module/Core/src/EventDispatcher/Async/AbstractNotifyVisitListener.php @@ -33,7 +33,7 @@ abstract class AbstractNotifyVisitListener extends AbstractAsyncListener $visitId = $visitLocated->visitId; $visit = $this->em->find(Visit::class, $visitId); - $name = $this->getRemoteSystemName(); + $name = $this->getRemoteSystem()->value; if ($visit === null) { $this->logger->warning( diff --git a/module/Core/src/EventDispatcher/Async/RemoteSystem.php b/module/Core/src/EventDispatcher/Async/RemoteSystem.php new file mode 100644 index 00000000..2cdda1d9 --- /dev/null +++ b/module/Core/src/EventDispatcher/Async/RemoteSystem.php @@ -0,0 +1,12 @@ +options->isEnabled(); } - protected function getRemoteSystemName(): string + protected function getRemoteSystem(): RemoteSystem { - return 'RabbitMQ'; + return RemoteSystem::RABBIT_MQ; } } diff --git a/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php b/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php index 2bf74bb2..fe777c69 100644 --- a/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php +++ b/module/Core/src/EventDispatcher/RabbitMq/NotifyVisitToRabbitMq.php @@ -11,6 +11,7 @@ use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Entity\Visit; use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener; +use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Shlinkio\Shlink\Core\EventDispatcher\Topic; use Shlinkio\Shlink\Core\Options\RabbitMqOptions; @@ -62,8 +63,8 @@ class NotifyVisitToRabbitMq extends AbstractNotifyVisitListener return $this->options->isEnabled(); } - protected function getRemoteSystemName(): string + protected function getRemoteSystem(): RemoteSystem { - return 'RabbitMQ'; + return RemoteSystem::RABBIT_MQ; } } diff --git a/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php b/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php index da871230..5cee9d5e 100644 --- a/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php +++ b/module/Core/src/EventDispatcher/RedisPubSub/NotifyNewShortUrlToRedis.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener; +use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; class NotifyNewShortUrlToRedis extends AbstractNotifyNewShortUrlListener @@ -27,8 +28,8 @@ class NotifyNewShortUrlToRedis extends AbstractNotifyNewShortUrlListener return $this->enabled; } - protected function getRemoteSystemName(): string + protected function getRemoteSystem(): RemoteSystem { - return 'Redis pub/sub'; + return RemoteSystem::REDIS_PUB_SUB; } } diff --git a/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php b/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php index 8b54eff0..ae349495 100644 --- a/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php +++ b/module/Core/src/EventDispatcher/RedisPubSub/NotifyVisitToRedis.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener; +use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem; use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; class NotifyVisitToRedis extends AbstractNotifyVisitListener @@ -27,8 +28,8 @@ class NotifyVisitToRedis extends AbstractNotifyVisitListener return $this->enabled; } - protected function getRemoteSystemName(): string + protected function getRemoteSystem(): RemoteSystem { - return 'Redis pub/sub'; + return RemoteSystem::REDIS_PUB_SUB; } }