mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Integrated PublishUpdatesGenerator in NotifyNewShortUrlToRedis listener
This commit is contained in:
parent
f071df325d
commit
fa5ebb1677
2 changed files with 4 additions and 9 deletions
|
@ -128,9 +128,9 @@ return [
|
|||
],
|
||||
EventDispatcher\RedisPubSub\NotifyNewShortUrlToRedis::class => [
|
||||
RedisPublishingHelper::class,
|
||||
EventDispatcher\PublishingUpdatesGenerator::class,
|
||||
'em',
|
||||
'Logger_Shlink',
|
||||
ShortUrl\Transformer\ShortUrlDataTransformer::class,
|
||||
'config.redis.pub_sub_enabled',
|
||||
],
|
||||
EventDispatcher\UpdateGeoLiteDb::class => [GeolocationDbUpdater::class, 'Logger_Shlink'],
|
||||
|
|
|
@ -6,21 +6,19 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub;
|
|||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
|
||||
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
||||
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
||||
use Throwable;
|
||||
|
||||
class NotifyNewShortUrlToRedis
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PublishingHelperInterface $redisHelper,
|
||||
private readonly PublishingUpdatesGeneratorInterface $updatesGenerator,
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly DataTransformerInterface $shortUrlTransformer,
|
||||
private readonly bool $enabled,
|
||||
) {
|
||||
}
|
||||
|
@ -43,10 +41,7 @@ class NotifyNewShortUrlToRedis
|
|||
}
|
||||
|
||||
try {
|
||||
$this->redisHelper->publishUpdate(Update::forTopicAndPayload(
|
||||
Topic::NEW_SHORT_URL->value,
|
||||
['shortUrl' => $this->shortUrlTransformer->transform($shortUrl)],
|
||||
));
|
||||
$this->redisHelper->publishUpdate($this->updatesGenerator->newShortUrlUpdate($shortUrl));
|
||||
} catch (Throwable $e) {
|
||||
$this->logger->debug('Error while trying to notify Redis pub/sub with new short URL. {e}', ['e' => $e]);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue