mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Defined enum with supported remote systems
This commit is contained in:
@@ -8,5 +8,5 @@ abstract class AbstractAsyncListener
|
||||
{
|
||||
abstract protected function isEnabled(): bool;
|
||||
|
||||
abstract protected function getRemoteSystemName(): string;
|
||||
abstract protected function getRemoteSystem(): RemoteSystem;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
12
module/Core/src/EventDispatcher/Async/RemoteSystem.php
Normal file
12
module/Core/src/EventDispatcher/Async/RemoteSystem.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\EventDispatcher\Async;
|
||||
|
||||
enum RemoteSystem: string
|
||||
{
|
||||
case MERCURE = 'Mercure';
|
||||
case RABBIT_MQ = 'RabbitMQ';
|
||||
case REDIS_PUB_SUB = 'Redis pub/sub';
|
||||
}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Shlinkio\Shlink\Core\EventDispatcher\Mercure;
|
||||
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem;
|
||||
|
||||
class NotifyNewShortUrlToMercure extends AbstractNotifyNewShortUrlListener
|
||||
{
|
||||
@@ -13,8 +14,8 @@ class NotifyNewShortUrlToMercure extends AbstractNotifyNewShortUrlListener
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getRemoteSystemName(): string
|
||||
protected function getRemoteSystem(): RemoteSystem
|
||||
{
|
||||
return 'Mercure';
|
||||
return RemoteSystem::MERCURE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Shlinkio\Shlink\Core\EventDispatcher\Mercure;
|
||||
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem;
|
||||
|
||||
class NotifyVisitToMercure extends AbstractNotifyVisitListener
|
||||
{
|
||||
@@ -13,8 +14,8 @@ class NotifyVisitToMercure extends AbstractNotifyVisitListener
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getRemoteSystemName(): string
|
||||
protected function getRemoteSystem(): RemoteSystem
|
||||
{
|
||||
return 'Mercure';
|
||||
return RemoteSystem::MERCURE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
||||
|
||||
@@ -28,8 +29,8 @@ class NotifyNewShortUrlToRabbitMq extends AbstractNotifyNewShortUrlListener
|
||||
return $this->options->isEnabled();
|
||||
}
|
||||
|
||||
protected function getRemoteSystemName(): string
|
||||
protected function getRemoteSystem(): RemoteSystem
|
||||
{
|
||||
return 'RabbitMQ';
|
||||
return RemoteSystem::RABBIT_MQ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user