Allow individual real-time updates topics to be enabled

This commit is contained in:
Alejandro Celaya
2025-07-03 10:10:06 +02:00
parent 436be1985c
commit fb995f2bea
18 changed files with 137 additions and 13 deletions

View File

@@ -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(),
);
}

View File

@@ -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]

View File

@@ -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),
);
}

View File

@@ -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),
);
}

View File

@@ -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,
);
}
}

View File

@@ -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,
);
}
}