mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 19:59:04 +03:00
Defined enum with supported remote systems
This commit is contained in:
parent
e36c4d397c
commit
4cf433a994
10 changed files with 33 additions and 15 deletions
|
@ -8,5 +8,5 @@ abstract class AbstractAsyncListener
|
||||||
{
|
{
|
||||||
abstract protected function isEnabled(): bool;
|
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;
|
$shortUrlId = $shortUrlCreated->shortUrlId;
|
||||||
$shortUrl = $this->em->find(ShortUrl::class, $shortUrlId);
|
$shortUrl = $this->em->find(ShortUrl::class, $shortUrlId);
|
||||||
$name = $this->getRemoteSystemName();
|
$name = $this->getRemoteSystem()->value;
|
||||||
|
|
||||||
if ($shortUrl === null) {
|
if ($shortUrl === null) {
|
||||||
$this->logger->warning(
|
$this->logger->warning(
|
||||||
|
|
|
@ -33,7 +33,7 @@ abstract class AbstractNotifyVisitListener extends AbstractAsyncListener
|
||||||
|
|
||||||
$visitId = $visitLocated->visitId;
|
$visitId = $visitLocated->visitId;
|
||||||
$visit = $this->em->find(Visit::class, $visitId);
|
$visit = $this->em->find(Visit::class, $visitId);
|
||||||
$name = $this->getRemoteSystemName();
|
$name = $this->getRemoteSystem()->value;
|
||||||
|
|
||||||
if ($visit === null) {
|
if ($visit === null) {
|
||||||
$this->logger->warning(
|
$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;
|
namespace Shlinkio\Shlink\Core\EventDispatcher\Mercure;
|
||||||
|
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener;
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem;
|
||||||
|
|
||||||
class NotifyNewShortUrlToMercure extends AbstractNotifyNewShortUrlListener
|
class NotifyNewShortUrlToMercure extends AbstractNotifyNewShortUrlListener
|
||||||
{
|
{
|
||||||
|
@ -13,8 +14,8 @@ class NotifyNewShortUrlToMercure extends AbstractNotifyNewShortUrlListener
|
||||||
return true;
|
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;
|
namespace Shlinkio\Shlink\Core\EventDispatcher\Mercure;
|
||||||
|
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener;
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem;
|
||||||
|
|
||||||
class NotifyVisitToMercure extends AbstractNotifyVisitListener
|
class NotifyVisitToMercure extends AbstractNotifyVisitListener
|
||||||
{
|
{
|
||||||
|
@ -13,8 +14,8 @@ class NotifyVisitToMercure extends AbstractNotifyVisitListener
|
||||||
return true;
|
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 Psr\Log\LoggerInterface;
|
||||||
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener;
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
||||||
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
||||||
|
|
||||||
|
@ -28,8 +29,8 @@ class NotifyNewShortUrlToRabbitMq extends AbstractNotifyNewShortUrlListener
|
||||||
return $this->options->isEnabled();
|
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\Common\UpdatePublishing\Update;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener;
|
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\PublishingUpdatesGeneratorInterface;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
|
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
|
||||||
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
||||||
|
@ -62,8 +63,8 @@ class NotifyVisitToRabbitMq extends AbstractNotifyVisitListener
|
||||||
return $this->options->isEnabled();
|
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 Psr\Log\LoggerInterface;
|
||||||
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener;
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyNewShortUrlListener;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Async\RemoteSystem;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
||||||
|
|
||||||
class NotifyNewShortUrlToRedis extends AbstractNotifyNewShortUrlListener
|
class NotifyNewShortUrlToRedis extends AbstractNotifyNewShortUrlListener
|
||||||
|
@ -27,8 +28,8 @@ class NotifyNewShortUrlToRedis extends AbstractNotifyNewShortUrlListener
|
||||||
return $this->enabled;
|
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 Psr\Log\LoggerInterface;
|
||||||
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Async\AbstractNotifyVisitListener;
|
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\PublishingUpdatesGeneratorInterface;
|
||||||
|
|
||||||
class NotifyVisitToRedis extends AbstractNotifyVisitListener
|
class NotifyVisitToRedis extends AbstractNotifyVisitListener
|
||||||
|
@ -27,8 +28,8 @@ class NotifyVisitToRedis extends AbstractNotifyVisitListener
|
||||||
return $this->enabled;
|
return $this->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRemoteSystemName(): string
|
protected function getRemoteSystem(): RemoteSystem
|
||||||
{
|
{
|
||||||
return 'Redis pub/sub';
|
return RemoteSystem::REDIS_PUB_SUB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue