From 8e5730f37409312f7bbbc7424514e7f74b2c16d9 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 12 Dec 2021 10:32:57 +0100 Subject: [PATCH] Renamed Rabbit instances to use RabbitMq --- README.md | 3 ++- config/autoload/rabbit.global.php | 14 +++++++------- config/autoload/rabbit.local.php.dist | 2 +- module/Core/config/event_dispatcher.config.php | 10 +++++----- ...VisitToRabbit.php => NotifyVisitToRabbitMq.php} | 2 +- ...abbitTest.php => NotifyVisitToRabbitMqTest.php} | 10 +++++----- 6 files changed, 21 insertions(+), 20 deletions(-) rename module/Core/src/EventDispatcher/{NotifyVisitToRabbit.php => NotifyVisitToRabbitMq.php} (99%) rename module/Core/test/EventDispatcher/{NotifyVisitToRabbitTest.php => NotifyVisitToRabbitMqTest.php} (96%) diff --git a/README.md b/README.md index 4fe5f5cf..9aad62d9 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,11 @@ The idea is that you can just generate a container using the image and provide t First, make sure the host where you are going to run shlink fulfills these requirements: -* PHP 8.0 +* PHP 8.0 or 8.1 * The next PHP extensions: json, curl, pdo, intl, gd and gmp. * apcu extension is recommended if you don't plan to use swoole or openswoole. * xml extension is required if you want to generate QR codes in svg format. + * sockets and bcmath extensions are required if you want to integrate with a RabbitMQ instance. * MySQL, MariaDB, PostgreSQL, Microsoft SQL Server or SQLite. * The web server of your choice with PHP integration (Apache or Nginx recommended). diff --git a/config/autoload/rabbit.global.php b/config/autoload/rabbit.global.php index a17e9887..b08dccf2 100644 --- a/config/autoload/rabbit.global.php +++ b/config/autoload/rabbit.global.php @@ -10,10 +10,10 @@ use function Shlinkio\Shlink\Common\env; return [ - 'rabbit' => [ + 'rabbitmq' => [ 'enabled' => (bool) env('RABBITMQ_ENABLED', false), 'host' => env('RABBITMQ_HOST'), - 'port' => env('RABBITMQ_PORT', '5672'), + 'port' => (int) env('RABBITMQ_PORT', '5672'), 'user' => env('RABBITMQ_USER'), 'password' => env('RABBITMQ_PASSWORD'), 'vhost' => env('RABBITMQ_VHOST', '/'), @@ -37,11 +37,11 @@ return [ ConfigAbstractFactory::class => [ AMQPStreamConnection::class => [ - 'config.rabbit.host', - 'config.rabbit.port', - 'config.rabbit.user', - 'config.rabbit.password', - 'config.rabbit.vhost', + 'config.rabbitmq.host', + 'config.rabbitmq.port', + 'config.rabbitmq.user', + 'config.rabbitmq.password', + 'config.rabbitmq.vhost', ], ], diff --git a/config/autoload/rabbit.local.php.dist b/config/autoload/rabbit.local.php.dist index 141b4b8b..83cd4a88 100644 --- a/config/autoload/rabbit.local.php.dist +++ b/config/autoload/rabbit.local.php.dist @@ -4,7 +4,7 @@ declare(strict_types=1); return [ - 'rabbit' => [ + 'rabbitmq' => [ 'enabled' => true, 'host' => 'shlink_rabbitmq', 'user' => 'rabbit', diff --git a/module/Core/config/event_dispatcher.config.php b/module/Core/config/event_dispatcher.config.php index a0f09beb..d47cc128 100644 --- a/module/Core/config/event_dispatcher.config.php +++ b/module/Core/config/event_dispatcher.config.php @@ -23,7 +23,7 @@ return [ 'async' => [ EventDispatcher\Event\VisitLocated::class => [ EventDispatcher\NotifyVisitToMercure::class, - EventDispatcher\NotifyVisitToRabbit::class, + EventDispatcher\NotifyVisitToRabbitMq::class, EventDispatcher\NotifyVisitToWebHooks::class, EventDispatcher\UpdateGeoLiteDb::class, ], @@ -35,7 +35,7 @@ return [ EventDispatcher\LocateVisit::class => ConfigAbstractFactory::class, EventDispatcher\NotifyVisitToWebHooks::class => ConfigAbstractFactory::class, EventDispatcher\NotifyVisitToMercure::class => ConfigAbstractFactory::class, - EventDispatcher\NotifyVisitToRabbit::class => ConfigAbstractFactory::class, + EventDispatcher\NotifyVisitToRabbitMq::class => ConfigAbstractFactory::class, EventDispatcher\UpdateGeoLiteDb::class => ConfigAbstractFactory::class, ], @@ -43,7 +43,7 @@ return [ EventDispatcher\NotifyVisitToMercure::class => [ EventDispatcher\CloseDbConnectionEventListenerDelegator::class, ], - EventDispatcher\NotifyVisitToRabbit::class => [ + EventDispatcher\NotifyVisitToRabbitMq::class => [ EventDispatcher\CloseDbConnectionEventListenerDelegator::class, ], EventDispatcher\NotifyVisitToWebHooks::class => [ @@ -74,12 +74,12 @@ return [ 'em', 'Logger_Shlink', ], - EventDispatcher\NotifyVisitToRabbit::class => [ + EventDispatcher\NotifyVisitToRabbitMq::class => [ AMQPStreamConnection::class, 'em', 'Logger_Shlink', Visit\Transformer\OrphanVisitDataTransformer::class, - 'config.rabbit.enabled', + 'config.rabbitmq.enabled', ], EventDispatcher\UpdateGeoLiteDb::class => [GeolocationDbUpdater::class, 'Logger_Shlink'], ], diff --git a/module/Core/src/EventDispatcher/NotifyVisitToRabbit.php b/module/Core/src/EventDispatcher/NotifyVisitToRabbitMq.php similarity index 99% rename from module/Core/src/EventDispatcher/NotifyVisitToRabbit.php rename to module/Core/src/EventDispatcher/NotifyVisitToRabbitMq.php index 6ff79eb8..f05ecf64 100644 --- a/module/Core/src/EventDispatcher/NotifyVisitToRabbit.php +++ b/module/Core/src/EventDispatcher/NotifyVisitToRabbitMq.php @@ -17,7 +17,7 @@ use Throwable; use function Shlinkio\Shlink\Common\json_encode; use function sprintf; -class NotifyVisitToRabbit +class NotifyVisitToRabbitMq { private const NEW_VISIT_QUEUE = 'https://shlink.io/new-visit'; private const NEW_ORPHAN_VISIT_QUEUE = 'https://shlink.io/new-orphan-visit'; diff --git a/module/Core/test/EventDispatcher/NotifyVisitToRabbitTest.php b/module/Core/test/EventDispatcher/NotifyVisitToRabbitMqTest.php similarity index 96% rename from module/Core/test/EventDispatcher/NotifyVisitToRabbitTest.php rename to module/Core/test/EventDispatcher/NotifyVisitToRabbitMqTest.php index 73a970fb..778da889 100644 --- a/module/Core/test/EventDispatcher/NotifyVisitToRabbitTest.php +++ b/module/Core/test/EventDispatcher/NotifyVisitToRabbitMqTest.php @@ -18,7 +18,7 @@ use RuntimeException; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\Visit; use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated; -use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToRabbit; +use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToRabbitMq; use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Model\Visitor; use Shlinkio\Shlink\Core\Visit\Transformer\OrphanVisitDataTransformer; @@ -27,11 +27,11 @@ use Throwable; use function count; use function Functional\contains; -class NotifyVisitToRabbitTest extends TestCase +class NotifyVisitToRabbitMqTest extends TestCase { use ProphecyTrait; - private NotifyVisitToRabbit $listener; + private NotifyVisitToRabbitMq $listener; private ObjectProphecy $connection; private ObjectProphecy $em; private ObjectProphecy $logger; @@ -49,7 +49,7 @@ class NotifyVisitToRabbitTest extends TestCase $this->em = $this->prophesize(EntityManagerInterface::class); $this->logger = $this->prophesize(LoggerInterface::class); - $this->listener = new NotifyVisitToRabbit( + $this->listener = new NotifyVisitToRabbitMq( $this->connection->reveal(), $this->em->reveal(), $this->logger->reveal(), @@ -61,7 +61,7 @@ class NotifyVisitToRabbitTest extends TestCase /** @test */ public function doesNothingWhenTheFeatureIsNotEnabled(): void { - $listener = new NotifyVisitToRabbit( + $listener = new NotifyVisitToRabbitMq( $this->connection->reveal(), $this->em->reveal(), $this->logger->reveal(),