From 0fe3bfb2f0c5008f5701fa3cf8431a415f762fda Mon Sep 17 00:00:00 2001 From: David Badura Date: Mon, 19 Feb 2024 13:43:33 +0100 Subject: [PATCH] rename TransactionalStore into LockableStore --- baseline.xml | 150 ++++++++---------- .../Command/ProjectionStatusCommand.php | 4 +- .../Projection/Store/DoctrineStore.php | 4 +- ...lStore.php => LockableProjectionStore.php} | 4 +- .../Projectionist/DefaultProjectionist.php | 5 +- 5 files changed, 73 insertions(+), 94 deletions(-) rename src/Projection/Projection/Store/{TransactionalStore.php => LockableProjectionStore.php} (51%) diff --git a/baseline.xml b/baseline.xml index 1fcbb2984..18f6289ae 100644 --- a/baseline.xml +++ b/baseline.xml @@ -1,8 +1,8 @@ - + - new static() + @@ -12,7 +12,7 @@ - class DoctrineHelper + @@ -27,7 +27,7 @@ - $aggregate::metadata() + ]]> @@ -35,7 +35,7 @@ - $reflectionType instanceof ReflectionIntersectionType + aggregateMetadata[$aggregate]]]> @@ -44,20 +44,12 @@ ]]> - - - projections))]]> - - - ]]> - - - $context + - $context + errorContext]]> @@ -66,24 +58,19 @@ - $method - $method - $method + + + - - - projectors]]> - - - new WeakMap() + - $payload[$key] + @@ -93,7 +80,7 @@ - $index + @@ -103,32 +90,32 @@ - $normalizedCustomHeaders + ]]> - $id - $name + + - $bus - $id - $repository - $store + + + + - $adapter - $bus - $id - $repository - $snapshotStore - $store + + + + + + @@ -136,85 +123,76 @@ id]]> - $bus - $id - $repository - $snapshotStore - $store - - - - - $bus - $id - $profile - $repository - $store + + + + + - $balanceInCents - $id - $name + + + - $id - $name + + - $id - $name + + - $id - $privacy - $visited + + + - $id - $name + + - $id - $name + + - $value + - $email - $id + + - $email - $id + + - $id + - $id + @@ -222,44 +200,44 @@ - $id + - $event + - $id + - $id + - $email - $id - $messages + + + - $id + - $id + - current - current - next + + + diff --git a/src/Console/Command/ProjectionStatusCommand.php b/src/Console/Command/ProjectionStatusCommand.php index b280489cd..391eca805 100644 --- a/src/Console/Command/ProjectionStatusCommand.php +++ b/src/Console/Command/ProjectionStatusCommand.php @@ -7,8 +7,8 @@ use Patchlevel\EventSourcing\Console\InputHelper; use Patchlevel\EventSourcing\Console\OutputStyle; use Patchlevel\EventSourcing\Projection\Projection\Projection; +use Patchlevel\EventSourcing\Projection\Projection\ProjectionNotFound; use Patchlevel\EventSourcing\Projection\Projection\Store\ErrorContext; -use RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -114,6 +114,6 @@ private function findProjection(array $projections, string $id): Projection } } - throw new RuntimeException('Projection not found'); + throw new ProjectionNotFound($id); } } diff --git a/src/Projection/Projection/Store/DoctrineStore.php b/src/Projection/Projection/Store/DoctrineStore.php index 437423b52..ac28d4925 100644 --- a/src/Projection/Projection/Store/DoctrineStore.php +++ b/src/Projection/Projection/Store/DoctrineStore.php @@ -34,7 +34,7 @@ * retry: int, * } */ -final class DoctrineStore implements ProjectionStore, TransactionalStore, SchemaConfigurator +final class DoctrineStore implements LockableProjectionStore, SchemaConfigurator { public function __construct( private readonly Connection $connection, @@ -156,7 +156,7 @@ public function remove(Projection $projection): void $this->connection->delete($this->projectionTable, ['id' => $projection->id()]); } - public function transactional(Closure $closure): void + public function inLock(Closure $closure): void { $this->connection->beginTransaction(); diff --git a/src/Projection/Projection/Store/TransactionalStore.php b/src/Projection/Projection/Store/LockableProjectionStore.php similarity index 51% rename from src/Projection/Projection/Store/TransactionalStore.php rename to src/Projection/Projection/Store/LockableProjectionStore.php index 13471d92a..a8e3d23d0 100644 --- a/src/Projection/Projection/Store/TransactionalStore.php +++ b/src/Projection/Projection/Store/LockableProjectionStore.php @@ -6,7 +6,7 @@ use Closure; -interface TransactionalStore +interface LockableProjectionStore extends ProjectionStore { - public function transactional(Closure $closure): void; + public function inLock(Closure $closure): void; } diff --git a/src/Projection/Projectionist/DefaultProjectionist.php b/src/Projection/Projectionist/DefaultProjectionist.php index c7c3893bb..bb2f65f4a 100644 --- a/src/Projection/Projectionist/DefaultProjectionist.php +++ b/src/Projection/Projectionist/DefaultProjectionist.php @@ -13,6 +13,7 @@ use Patchlevel\EventSourcing\Projection\Projection\ProjectionCriteria; use Patchlevel\EventSourcing\Projection\Projection\ProjectionError; use Patchlevel\EventSourcing\Projection\Projection\ProjectionStatus; +use Patchlevel\EventSourcing\Projection\Projection\Store\LockableProjectionStore; use Patchlevel\EventSourcing\Projection\Projection\Store\ProjectionStore; use Patchlevel\EventSourcing\Store\Criteria; use Patchlevel\EventSourcing\Store\Store; @@ -823,13 +824,13 @@ private function lowestProjectionPosition(array $projections): int /** @param Closure(list):void $closure */ private function findForUpdate(ProjectionCriteria $criteria, Closure $closure): void { - if (!$this->projectionStore instanceof Store) { + if (!$this->projectionStore instanceof LockableProjectionStore) { $closure($this->projectionStore->find($criteria)); return; } - $this->projectionStore->transactional(function () use ($closure, $criteria): void { + $this->projectionStore->inLock(function () use ($closure, $criteria): void { $projections = $this->projectionStore->find($criteria); $closure($projections);