mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 09:03:07 +03:00
Merge pull request #1061 from acelaya-forks/feature/update-mercure
Updated to symfony/mercure 0.5
This commit is contained in:
commit
731dc64f44
6 changed files with 22 additions and 21 deletions
|
@ -46,7 +46,7 @@
|
|||
"predis/predis": "^1.1",
|
||||
"pugx/shortid-php": "^0.7",
|
||||
"ramsey/uuid": "^3.9",
|
||||
"shlinkio/shlink-common": "^3.6",
|
||||
"shlinkio/shlink-common": "dev-main#3777189 as 3.7",
|
||||
"shlinkio/shlink-config": "^1.0",
|
||||
"shlinkio/shlink-event-dispatcher": "^2.1",
|
||||
"shlinkio/shlink-importer": "^2.2",
|
||||
|
@ -55,7 +55,7 @@
|
|||
"symfony/console": "^5.1",
|
||||
"symfony/filesystem": "^5.1",
|
||||
"symfony/lock": "^5.1",
|
||||
"symfony/mercure": "^0.4.1",
|
||||
"symfony/mercure": "^0.5.1",
|
||||
"symfony/process": "^5.1",
|
||||
"symfony/string": "^5.1"
|
||||
},
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
use Laminas\ServiceManager\Proxy\LazyServiceFactory;
|
||||
use Shlinkio\Shlink\Common\Mercure\LcobucciJwtProvider;
|
||||
use Symfony\Component\Mercure\Publisher;
|
||||
use Symfony\Component\Mercure\PublisherInterface;
|
||||
use Symfony\Component\Mercure\Hub;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
|
||||
return [
|
||||
|
||||
|
@ -21,14 +21,14 @@ return [
|
|||
LcobucciJwtProvider::class => [
|
||||
LazyServiceFactory::class,
|
||||
],
|
||||
Publisher::class => [
|
||||
Hub::class => [
|
||||
LazyServiceFactory::class,
|
||||
],
|
||||
],
|
||||
'lazy_services' => [
|
||||
'class_map' => [
|
||||
LcobucciJwtProvider::class => LcobucciJwtProvider::class,
|
||||
Publisher::class => PublisherInterface::class,
|
||||
Hub::class => HubInterface::class,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
@ -8,7 +8,7 @@ use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
|||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Shlinkio\Shlink\CLI\Util\GeolocationDbUpdater;
|
||||
use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
|
||||
use Symfony\Component\Mercure\Publisher;
|
||||
use Symfony\Component\Mercure\Hub;
|
||||
|
||||
return [
|
||||
|
||||
|
@ -57,7 +57,7 @@ return [
|
|||
Options\AppOptions::class,
|
||||
],
|
||||
EventDispatcher\NotifyVisitToMercure::class => [
|
||||
Publisher::class,
|
||||
Hub::class,
|
||||
Mercure\MercureUpdatesGenerator::class,
|
||||
'em',
|
||||
'Logger_Shlink',
|
||||
|
|
|
@ -9,7 +9,7 @@ use Psr\Log\LoggerInterface;
|
|||
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
||||
use Symfony\Component\Mercure\PublisherInterface;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
use Symfony\Component\Mercure\Update;
|
||||
use Throwable;
|
||||
|
||||
|
@ -17,18 +17,18 @@ use function Functional\each;
|
|||
|
||||
class NotifyVisitToMercure
|
||||
{
|
||||
private PublisherInterface $publisher;
|
||||
private HubInterface $hub;
|
||||
private MercureUpdatesGeneratorInterface $updatesGenerator;
|
||||
private EntityManagerInterface $em;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
PublisherInterface $publisher,
|
||||
HubInterface $hub,
|
||||
MercureUpdatesGeneratorInterface $updatesGenerator,
|
||||
EntityManagerInterface $em,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->publisher = $publisher;
|
||||
$this->hub = $hub;
|
||||
$this->em = $em;
|
||||
$this->logger = $logger;
|
||||
$this->updatesGenerator = $updatesGenerator;
|
||||
|
@ -48,7 +48,7 @@ class NotifyVisitToMercure
|
|||
}
|
||||
|
||||
try {
|
||||
each($this->determineUpdatesForVisit($visit), fn (Update $update) => ($this->publisher)($update));
|
||||
each($this->determineUpdatesForVisit($visit), fn (Update $update) => $this->hub->publish($update));
|
||||
} catch (Throwable $e) {
|
||||
$this->logger->debug('Error while trying to notify mercure hub with new visit. {e}', [
|
||||
'e' => $e,
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
|||
use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToMercure;
|
||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
use Symfony\Component\Mercure\PublisherInterface;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
use Symfony\Component\Mercure\Update;
|
||||
|
||||
class NotifyVisitToMercureTest extends TestCase
|
||||
|
@ -25,20 +25,20 @@ class NotifyVisitToMercureTest extends TestCase
|
|||
use ProphecyTrait;
|
||||
|
||||
private NotifyVisitToMercure $listener;
|
||||
private ObjectProphecy $publisher;
|
||||
private ObjectProphecy $hub;
|
||||
private ObjectProphecy $updatesGenerator;
|
||||
private ObjectProphecy $em;
|
||||
private ObjectProphecy $logger;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->publisher = $this->prophesize(PublisherInterface::class);
|
||||
$this->hub = $this->prophesize(HubInterface::class);
|
||||
$this->updatesGenerator = $this->prophesize(MercureUpdatesGeneratorInterface::class);
|
||||
$this->em = $this->prophesize(EntityManagerInterface::class);
|
||||
$this->logger = $this->prophesize(LoggerInterface::class);
|
||||
|
||||
$this->listener = new NotifyVisitToMercure(
|
||||
$this->publisher->reveal(),
|
||||
$this->hub->reveal(),
|
||||
$this->updatesGenerator->reveal(),
|
||||
$this->em->reveal(),
|
||||
$this->logger->reveal(),
|
||||
|
@ -60,7 +60,7 @@ class NotifyVisitToMercureTest extends TestCase
|
|||
);
|
||||
$buildNewOrphanVisitUpdate = $this->updatesGenerator->newOrphanVisitUpdate(Argument::type(Visit::class));
|
||||
$buildNewVisitUpdate = $this->updatesGenerator->newVisitUpdate(Argument::type(Visit::class));
|
||||
$publish = $this->publisher->__invoke(Argument::type(Update::class));
|
||||
$publish = $this->hub->publish(Argument::type(Update::class));
|
||||
|
||||
($this->listener)(new VisitLocated($visitId));
|
||||
|
||||
|
@ -86,7 +86,7 @@ class NotifyVisitToMercureTest extends TestCase
|
|||
$buildNewShortUrlVisitUpdate = $this->updatesGenerator->newShortUrlVisitUpdate($visit)->willReturn($update);
|
||||
$buildNewOrphanVisitUpdate = $this->updatesGenerator->newOrphanVisitUpdate($visit)->willReturn($update);
|
||||
$buildNewVisitUpdate = $this->updatesGenerator->newVisitUpdate($visit)->willReturn($update);
|
||||
$publish = $this->publisher->__invoke($update);
|
||||
$publish = $this->hub->publish($update);
|
||||
|
||||
($this->listener)(new VisitLocated($visitId));
|
||||
|
||||
|
@ -115,7 +115,7 @@ class NotifyVisitToMercureTest extends TestCase
|
|||
$buildNewShortUrlVisitUpdate = $this->updatesGenerator->newShortUrlVisitUpdate($visit)->willReturn($update);
|
||||
$buildNewOrphanVisitUpdate = $this->updatesGenerator->newOrphanVisitUpdate($visit)->willReturn($update);
|
||||
$buildNewVisitUpdate = $this->updatesGenerator->newVisitUpdate($visit)->willReturn($update);
|
||||
$publish = $this->publisher->__invoke($update)->willThrow($e);
|
||||
$publish = $this->hub->publish($update)->willThrow($e);
|
||||
|
||||
($this->listener)(new VisitLocated($visitId));
|
||||
|
||||
|
@ -143,7 +143,7 @@ class NotifyVisitToMercureTest extends TestCase
|
|||
$buildNewShortUrlVisitUpdate = $this->updatesGenerator->newShortUrlVisitUpdate($visit)->willReturn($update);
|
||||
$buildNewOrphanVisitUpdate = $this->updatesGenerator->newOrphanVisitUpdate($visit)->willReturn($update);
|
||||
$buildNewVisitUpdate = $this->updatesGenerator->newVisitUpdate($visit)->willReturn($update);
|
||||
$publish = $this->publisher->__invoke($update);
|
||||
$publish = $this->hub->publish($update);
|
||||
|
||||
($this->listener)(new VisitLocated($visitId));
|
||||
|
||||
|
|
|
@ -3,3 +3,4 @@ parameters:
|
|||
checkGenericClassInNonGenericObjectType: false
|
||||
ignoreErrors:
|
||||
- '#If condition is always false#'
|
||||
- '#setOrderBy\(\) expects array\<int, string\>, array\<string, string\> given#'
|
||||
|
|
Loading…
Reference in a new issue