Skip to content

Commit 4dfe48c

Browse files
authored
Merge pull request #289 from patchlevel/3.14.x-merge-up-into-3.15.x_dSynZRWi
Merge release 3.14.1 into 3.15.x
2 parents 87db491 + 9f771c6 commit 4dfe48c

4 files changed

Lines changed: 55 additions & 4 deletions

File tree

src/Clock/FrozenClockFactory.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Patchlevel\EventSourcingBundle\Clock;
6+
7+
use DateTimeImmutable;
8+
use Patchlevel\EventSourcing\Clock\FrozenClock;
9+
10+
/** @internal */
11+
final class FrozenClockFactory
12+
{
13+
public static function create(string $dateTimeString): FrozenClock
14+
{
15+
return new FrozenClock(new DateTimeImmutable($dateTimeString));
16+
}
17+
}

src/DependencyInjection/PatchlevelEventSourcingExtension.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Patchlevel\EventSourcingBundle\DependencyInjection;
66

7-
use DateInterval;
8-
use DateTimeImmutable;
97
use Doctrine\DBAL\Connection;
108
use Doctrine\Migrations\Configuration\Connection\ExistingConnection;
119
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
@@ -117,6 +115,7 @@
117115
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessorRepository;
118116
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberHelper;
119117
use Patchlevel\EventSourcingBundle\Attribute\AsListener;
118+
use Patchlevel\EventSourcingBundle\Clock\FrozenClockFactory;
120119
use Patchlevel\EventSourcingBundle\Command\StoreMigrateCommand;
121120
use Patchlevel\EventSourcingBundle\CommandBus\SymfonyCommandBus;
122121
use Patchlevel\EventSourcingBundle\DataCollector\EventSourcingCollector;
@@ -126,6 +125,7 @@
126125
use Patchlevel\EventSourcingBundle\QueryBus\SymfonyQueryBus;
127126
use Patchlevel\EventSourcingBundle\RequestListener\AutoSetupListener;
128127
use Patchlevel\EventSourcingBundle\RequestListener\SubscriptionRebuildAfterFileChangeListener;
128+
use Patchlevel\EventSourcingBundle\Subscription\Engine\GapResolverMessageLoaderFactory;
129129
use Patchlevel\EventSourcingBundle\Subscription\ResetServicesListener;
130130
use Patchlevel\EventSourcingBundle\Subscription\StaticInMemorySubscriptionStoreFactory;
131131
use Patchlevel\EventSourcingBundle\ValueResolver\AggregateRootIdValueResolver;
@@ -354,11 +354,12 @@ private function configureMessageLoader(array $config, ContainerBuilder $contain
354354
}
355355

356356
$container->register(GapResolverStoreMessageLoader::class)
357+
->setFactory([GapResolverMessageLoaderFactory::class, 'create'])
357358
->setArguments([
358359
new Reference(Store::class),
359360
new Reference('event_sourcing.clock'),
360361
$config['subscription']['gap_detection']['retries_in_ms'],
361-
new DateInterval($config['subscription']['gap_detection']['detection_window']),
362+
$config['subscription']['gap_detection']['detection_window'],
362363
]);
363364

364365
$container->setAlias(MessageLoader::class, GapResolverStoreMessageLoader::class);
@@ -1068,7 +1069,8 @@ private function configureClock(array $config, ContainerBuilder $container): voi
10681069
{
10691070
if ($config['clock']['freeze'] !== null) {
10701071
$container->register(FrozenClock::class)
1071-
->setArguments([new DateTimeImmutable($config['clock']['freeze'])]);
1072+
->setFactory([FrozenClockFactory::class, 'create'])
1073+
->setArguments([$config['clock']['freeze']]);
10721074

10731075
$container->setAlias('event_sourcing.clock', FrozenClock::class);
10741076

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Patchlevel\EventSourcingBundle\Subscription\Engine;
6+
7+
use DateInterval;
8+
use Patchlevel\EventSourcing\Store\Store;
9+
use Patchlevel\EventSourcing\Subscription\Engine\GapResolverStoreMessageLoader;
10+
use Psr\Clock\ClockInterface;
11+
12+
/** @internal */
13+
final class GapResolverMessageLoaderFactory
14+
{
15+
/** @param list<int> $retriesInMs in milliseconds */
16+
public static function create(
17+
Store $store,
18+
ClockInterface $clock,
19+
array $retriesInMs,
20+
string|null $detectionWindow,
21+
): GapResolverStoreMessageLoader {
22+
return new GapResolverStoreMessageLoader(
23+
$store,
24+
$clock,
25+
$retriesInMs,
26+
$detectionWindow !== null ? new DateInterval($detectionWindow) : null,
27+
);
28+
}
29+
}

tests/Unit/PatchlevelEventSourcingBundleTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
use Symfony\Component\DependencyInjection\ChildDefinition;
116116
use Symfony\Component\DependencyInjection\ContainerBuilder;
117117
use Symfony\Component\DependencyInjection\Definition;
118+
use Symfony\Component\DependencyInjection\Dumper\XmlDumper;
118119
use Symfony\Component\DependencyInjection\Reference;
119120
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
120121
use Symfony\Component\Messenger\MessageBusInterface;
@@ -1585,5 +1586,7 @@ private function compileContainer(ContainerBuilder $container, array $config): v
15851586
$compilerPassConfig->addPass(new TestCaseAllPublicCompilerPass());
15861587

15871588
$container->compile();
1589+
1590+
(new XmlDumper($container))->dump();
15881591
}
15891592
}

0 commit comments

Comments
 (0)