Skip to content

Commit 019c3bf

Browse files
authored
Merge pull request #761 from patchlevel/merge-stream-store-into-store-interface
Merge `StreamStore` into `Store` interface
2 parents 3c95103 + 7be26cf commit 019c3bf

12 files changed

Lines changed: 48 additions & 52 deletions

File tree

baseline.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@
8888
<PropertyTypeCoercion>
8989
<code><![CDATA[new WeakMap()]]></code>
9090
</PropertyTypeCoercion>
91-
<UndefinedInterfaceMethod>
92-
<code><![CDATA[archive]]></code>
93-
</UndefinedInterfaceMethod>
9491
</file>
9592
<file src="src/Schema/DoctrineHelper.php">
9693
<InternalMethod>

docs/pages/UPGRADE-4.0.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ $subscriptionEngine = new DefaultSubscriptionEngine(
8585
```
8686
## Store
8787

88+
### StreamStore
89+
90+
`StreamStore` interface was merged with `Store` interface.
91+
8892
### DoctrineDbalStore
8993

9094
`DoctrineDbalStore` has been removed in favor of `StreamDoctrineDbalStore`.
@@ -94,7 +98,10 @@ And all the associated classes:
9498
* `Patchlevel\EventSourcing\Store\Criteria\AggregateIdCriterion`
9599
* `Patchlevel\EventSourcing\Store\DoctrineDbalStore`
96100
* `Patchlevel\EventSourcing\Store\DoctrineDbalStoreStream`
97-
* `Patchlevel\EventSourcing\Store\ReadOnlyStore`
101+
102+
### StreamReadOnlyStore
103+
104+
`StreamReadOnlyStore` was been merged in `ReadOnlyStore`.
98105

99106
## Message
100107

docs/pages/store.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ It passes all methods to the underlying store, but throws an `StoreIsReadOnly` e
8383
operations.
8484

8585
```php
86-
use Patchlevel\EventSourcing\Store\StreamReadOnlyStore;
86+
use Patchlevel\EventSourcing\Store\ReadOnlyStore;
8787
use Patchlevel\EventSourcing\Store\StreamStore;
8888

8989
/** @var StreamStore $store */
90-
$readOnlyStore = new StreamReadOnlyStore($store);
90+
$readOnlyStore = new ReadOnlyStore($store);
9191
```
9292
## Schema
9393

src/Repository/DefaultRepository.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Patchlevel\EventSourcing\Store\Store;
2626
use Patchlevel\EventSourcing\Store\Stream;
2727
use Patchlevel\EventSourcing\Store\StreamStartHeader;
28-
use Patchlevel\EventSourcing\Store\StreamStore;
2928
use Patchlevel\EventSourcing\Store\UniqueConstraintViolation;
3029
use Psr\Clock\ClockInterface;
3130
use Psr\Log\LoggerInterface;
@@ -253,7 +252,7 @@ static function (object $event) use (
253252
);
254253

255254
try {
256-
if ($archiveTo !== null && $this->store instanceof StreamStore) {
255+
if ($archiveTo !== null) {
257256
$this->store->transactional(
258257
function () use ($messages, $streamName, $archiveTo): void {
259258
$this->store->save(...$messages);

src/Store/InMemoryStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
use const ARRAY_FILTER_USE_BOTH;
3232

33-
final class InMemoryStore implements StreamStore
33+
final class InMemoryStore implements Store
3434
{
3535
/** @param array<positive-int|0, Message> $messages */
3636
public function __construct(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
use Patchlevel\EventSourcing\Store\Criteria\Criteria;
1010
use Psr\Log\LoggerInterface;
1111

12-
final class StreamReadOnlyStore implements StreamStore
12+
final class ReadOnlyStore implements Store
1313
{
1414
public function __construct(
15-
private readonly StreamStore $store,
15+
private readonly Store $store,
1616
private readonly LoggerInterface|null $logger = null,
1717
) {
1818
}

src/Store/Store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,11 @@ public function save(Message ...$messages): void;
3131
* @template ClosureReturn
3232
*/
3333
public function transactional(Closure $function): void;
34+
35+
/** @return list<string> */
36+
public function streams(): array;
37+
38+
public function remove(Criteria|null $criteria = null): void;
39+
40+
public function archive(Criteria|null $criteria = null): void;
3441
}

src/Store/StreamDoctrineDbalStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
use function str_contains;
5959
use function str_replace;
6060

61-
final class StreamDoctrineDbalStore implements StreamStore, SubscriptionStore, DoctrineSchemaConfigurator
61+
final class StreamDoctrineDbalStore implements Store, SubscriptionStore, DoctrineSchemaConfigurator
6262
{
6363
/**
6464
* PostgreSQL has a limit of 65535 parameters in a single query.

src/Store/StreamStore.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/Integration/Store/StreamDoctrineDbalStoreTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
use Patchlevel\EventSourcing\Store\Header\PlayheadHeader;
2020
use Patchlevel\EventSourcing\Store\Header\RecordedOnHeader;
2121
use Patchlevel\EventSourcing\Store\Header\StreamNameHeader;
22+
use Patchlevel\EventSourcing\Store\Store;
2223
use Patchlevel\EventSourcing\Store\StreamDoctrineDbalStore;
23-
use Patchlevel\EventSourcing\Store\StreamStore;
2424
use Patchlevel\EventSourcing\Store\UniqueConstraintViolation;
2525
use Patchlevel\EventSourcing\Tests\DbalManager;
2626
use Patchlevel\EventSourcing\Tests\Integration\Store\Events\ExternEvent;
@@ -37,7 +37,7 @@
3737
final class StreamDoctrineDbalStoreTest extends TestCase
3838
{
3939
private Connection $connection;
40-
private StreamStore $store;
40+
private Store $store;
4141

4242
private ClockInterface $clock;
4343

0 commit comments

Comments
 (0)