Skip to content

Commit

Permalink
improve batching
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Sep 20, 2024
1 parent 5fa4ff2 commit 3ae0fd0
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 116 deletions.
18 changes: 17 additions & 1 deletion baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/Aggregate/AggregateRootBehaviour.php">
<UnsafeInstantiation>
<code><![CDATA[new static()]]></code>
Expand Down Expand Up @@ -102,6 +102,11 @@
<code><![CDATA[$data['playhead'] === null ? null : (int)$data['playhead']]]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/Subscription/Engine/DefaultSubscriptionEngine.php">
<PropertyTypeCoercion>
<code><![CDATA[new WeakMap()]]></code>
</PropertyTypeCoercion>
</file>
<file src="src/Subscription/Store/DoctrineSubscriptionStore.php">
<MixedArgument>
<code><![CDATA[$context]]></code>
Expand All @@ -119,6 +124,9 @@
<code><![CDATA[$arguments[]]]></code>
</MixedAssignment>
<MixedMethodCall>
<code><![CDATA[$method]]></code>
<code><![CDATA[$method]]></code>
<code><![CDATA[$method]]></code>
<code><![CDATA[$method]]></code>
<code><![CDATA[$method]]></code>
<code><![CDATA[$methodName]]></code>
Expand Down Expand Up @@ -174,6 +182,14 @@
<code><![CDATA[$store]]></code>
</MissingConstructor>
</file>
<file src="tests/Benchmark/SubscriptionEngineBatchBench.php">
<MissingConstructor>
<code><![CDATA[$id]]></code>
<code><![CDATA[$repository]]></code>
<code><![CDATA[$store]]></code>
<code><![CDATA[$subscriptionEngine]]></code>
</MissingConstructor>
</file>
<file src="tests/Benchmark/SubscriptionEngineBench.php">
<MissingConstructor>
<code><![CDATA[$id]]></code>
Expand Down
20 changes: 11 additions & 9 deletions src/Metadata/Subscriber/AttributeSubscriberMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,19 @@ public function metadata(string $subscriber): SubscriberMetadata
$commitBatchMethod = $method->getName();
}

if ($method->getAttributes(RollbackBatch::class)) {
if ($rollbackBatchMethod !== null) {
throw new DuplicateBeginBatchMethod(
$subscriber,
$rollbackBatchMethod,
$method->getName(),
);
}
if (!$method->getAttributes(RollbackBatch::class)) {
continue;
}

$rollbackBatchMethod = $method->getName();
if ($rollbackBatchMethod !== null) {
throw new DuplicateBeginBatchMethod(
$subscriber,
$rollbackBatchMethod,
$method->getName(),
);
}

$rollbackBatchMethod = $method->getName();
}

$metadata = new SubscriberMetadata(
Expand Down
1 change: 1 addition & 0 deletions src/Metadata/Subscriber/DuplicateBeginBatchMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Patchlevel\EventSourcing\Metadata\Subscriber;

use Patchlevel\EventSourcing\Metadata\MetadataException;

use function sprintf;

final class DuplicateBeginBatchMethod extends MetadataException
Expand Down
1 change: 1 addition & 0 deletions src/Metadata/Subscriber/DuplicateCommitBatchMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Patchlevel\EventSourcing\Metadata\Subscriber;

use Patchlevel\EventSourcing\Metadata\MetadataException;

use function sprintf;

final class DuplicateCommitBatchMethod extends MetadataException
Expand Down
1 change: 1 addition & 0 deletions src/Metadata/Subscriber/DuplicateRollbackBatchMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Patchlevel\EventSourcing\Metadata\Subscriber;

use Patchlevel\EventSourcing\Metadata\MetadataException;

use function sprintf;

final class DuplicateRollbackBatchMethod extends MetadataException
Expand Down
Loading

0 comments on commit 3ae0fd0

Please sign in to comment.