Flipped events triggered when locating a visit, so that geolocation is done synchronously

This commit is contained in:
Alejandro Celaya 2021-04-07 11:35:02 +02:00
parent 0621ae7735
commit b4d137375a
2 changed files with 17 additions and 8 deletions

View file

@ -13,6 +13,11 @@ class GeolocationDbUpdateFailedException extends RuntimeException implements Exc
{ {
private bool $olderDbExists; private bool $olderDbExists;
private function __construct(string $message, int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
public static function withOlderDb(?Throwable $prev = null): self public static function withOlderDb(?Throwable $prev = null): self
{ {
$e = new self( $e = new self(

View file

@ -6,7 +6,7 @@ namespace Shlinkio\Shlink\Core;
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory; use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Psr\EventDispatcher\EventDispatcherInterface; use Psr\EventDispatcher\EventDispatcherInterface;
use Shlinkio\Shlink\CLI\Util\GeolocationDbUpdater; use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdater;
use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface; use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
use Symfony\Component\Mercure\Hub; use Symfony\Component\Mercure\Hub;
@ -14,14 +14,15 @@ return [
'events' => [ 'events' => [
'regular' => [ 'regular' => [
EventDispatcher\Event\VisitLocated::class => [ EventDispatcher\Event\UrlVisited::class => [
EventDispatcher\NotifyVisitToMercure::class, EventDispatcher\LocateVisit::class,
EventDispatcher\NotifyVisitToWebHooks::class,
], ],
], ],
'async' => [ 'async' => [
EventDispatcher\Event\UrlVisited::class => [ EventDispatcher\Event\VisitLocated::class => [
EventDispatcher\LocateVisit::class, EventDispatcher\NotifyVisitToMercure::class,
EventDispatcher\NotifyVisitToWebHooks::class,
// EventDispatcher\UpdateGeoliteDb::class,
], ],
], ],
], ],
@ -34,7 +35,10 @@ return [
], ],
'delegators' => [ 'delegators' => [
EventDispatcher\LocateVisit::class => [ EventDispatcher\NotifyVisitToMercure::class => [
EventDispatcher\CloseDbConnectionEventListenerDelegator::class,
],
EventDispatcher\NotifyVisitToWebHooks::class => [
EventDispatcher\CloseDbConnectionEventListenerDelegator::class, EventDispatcher\CloseDbConnectionEventListenerDelegator::class,
], ],
], ],
@ -45,7 +49,7 @@ return [
IpLocationResolverInterface::class, IpLocationResolverInterface::class,
'em', 'em',
'Logger_Shlink', 'Logger_Shlink',
GeolocationDbUpdater::class, DbUpdater::class,
EventDispatcherInterface::class, EventDispatcherInterface::class,
], ],
EventDispatcher\NotifyVisitToWebHooks::class => [ EventDispatcher\NotifyVisitToWebHooks::class => [