Skip to content

Commit e769dfc

Browse files
committed
merge stream store into store interface
1 parent ee4d0a8 commit e769dfc

11 files changed

Lines changed: 44 additions & 48 deletions

File tree

docs/pages/UPGRADE-4.0.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ $subscriptionEngine = new DefaultSubscriptionEngine(
6464

6565
## Store
6666

67+
### StreamStore
68+
69+
`StreamStore` interface was merged with `Store` interface.
70+
6771
### DoctrineDbalStore
6872

6973
`DoctrineDbalStore` has been removed in favor of `StreamDoctrineDbalStore`.
@@ -73,7 +77,10 @@ And all the associated classes:
7377
* `Patchlevel\EventSourcing\Store\Criteria\AggregateIdCriterion`
7478
* `Patchlevel\EventSourcing\Store\DoctrineDbalStore`
7579
* `Patchlevel\EventSourcing\Store\DoctrineDbalStoreStream`
76-
* `Patchlevel\EventSourcing\Store\ReadOnlyStore`
80+
81+
### StreamReadOnlyStore
82+
83+
`StreamReadOnlyStore` has been removed in favor of `ReadOnlyStore`.
7784

7885
## Message
7986

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
@@ -57,7 +57,7 @@
5757
use function str_contains;
5858
use function str_replace;
5959

60-
final class StreamDoctrineDbalStore implements StreamStore, SubscriptionStore, DoctrineSchemaConfigurator
60+
final class StreamDoctrineDbalStore implements Store, SubscriptionStore, DoctrineSchemaConfigurator
6161
{
6262
/**
6363
* 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,7 +19,7 @@
1919
use Patchlevel\EventSourcing\Store\Header\RecordedOnHeader;
2020
use Patchlevel\EventSourcing\Store\Header\StreamNameHeader;
2121
use Patchlevel\EventSourcing\Store\StreamDoctrineDbalStore;
22-
use Patchlevel\EventSourcing\Store\StreamStore;
22+
use Patchlevel\EventSourcing\Store\Store;
2323
use Patchlevel\EventSourcing\Store\UniqueConstraintViolation;
2424
use Patchlevel\EventSourcing\Tests\DbalManager;
2525
use Patchlevel\EventSourcing\Tests\Integration\Store\Events\ExternEvent;
@@ -36,7 +36,7 @@
3636
final class StreamDoctrineDbalStoreTest extends TestCase
3737
{
3838
private Connection $connection;
39-
private StreamStore $store;
39+
private Store $store;
4040

4141
private ClockInterface $clock;
4242

tests/Unit/Repository/DefaultRepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ public function testLoadAggregateWithoutSnapshot(): void
693693

694694
public function testSaveAggregateInOtherStream(): void
695695
{
696-
$store = $this->createMock(StreamStore::class);
696+
$store = $this->createMock(Store::class);
697697
$store
698698
->expects($this->once())
699699
->method('save')
@@ -717,7 +717,7 @@ public function testSaveAggregateInOtherStream(): void
717717

718718
public function testLoadAggregateFromOtherStream(): void
719719
{
720-
$store = $this->createMock(StreamStore::class);
720+
$store = $this->createMock(Store::class);
721721

722722
$store
723723
->expects($this->once())

0 commit comments

Comments
 (0)