Skip to content

Commit 07465d7

Browse files
DavidBaduraclaude
andcommitted
docs: update upgrade guide and message docs for 4.0 breaking changes
Document the breaking changes from the merged 4.0 PRs that were missing from the upgrade guide: - stream refactor (#847): Store\Stream interface replaced by the concrete Message\Stream class, removed store-specific stream implementations, Message\Pipe removed in favor of Stream::transform() - removed deprecated SubscriberHelper and SubscriberUtil (#805) - removed SubscriberAccessor / RealSubscriberAccessor interfaces and deprecated accessor methods, removed AggregateIdArgumentResolver (#756) - ArgumentMetadata now carries a symfony/type-info Type (#814) Also update the message docs Pipe section to use the new Stream API. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 466f278 commit 07465d7

2 files changed

Lines changed: 97 additions & 6 deletions

File tree

docs/UPGRADE-4.0.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,48 @@ $subscriptionEngine = new DefaultSubscriptionEngine(
8686
RetryStrategyRepository::withDefault($retryStrategy),
8787
);
8888
```
89+
90+
### SubscriberHelper and SubscriberUtil
91+
92+
The deprecated `Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberHelper`
93+
and the `Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberUtil` trait have been removed.
94+
95+
If you need the subscriber id, read it from the metadata instead:
96+
97+
```php
98+
use Patchlevel\EventSourcing\Metadata\Subscriber\AttributeSubscriberMetadataFactory;
99+
100+
$metadata = (new AttributeSubscriberMetadataFactory())->metadata($subscriber::class);
101+
$subscriberId = $metadata->id;
102+
```
103+
104+
### SubscriberAccessor and RealSubscriberAccessor
105+
106+
The `Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessor` and
107+
`Patchlevel\EventSourcing\Subscription\Subscriber\RealSubscriberAccessor` interfaces have been removed.
108+
Use `Patchlevel\EventSourcing\Subscription\Subscriber\MetadataSubscriberAccessor` directly.
109+
110+
Accordingly, `SubscriberAccessorRepository::get()` now returns a `MetadataSubscriberAccessor|null`
111+
instead of a `SubscriberAccessor|null`.
112+
113+
The deprecated methods `id()`, `group()` and `runMode()` on `MetadataSubscriberAccessor` have been removed.
114+
Use `->metadata()->id`, `->metadata()->group` and `->metadata()->runMode` instead.
115+
116+
### AggregateIdArgumentResolver
117+
118+
The deprecated `Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\AggregateIdArgumentResolver`
119+
has been removed. Automatically resolving the aggregate id in a stream store is not possible.
120+
Add the aggregate id to your events instead.
121+
122+
### ArgumentMetadata
123+
124+
The subscriber argument resolver now uses `symfony/type-info` to describe argument types.
125+
126+
`Patchlevel\EventSourcing\Metadata\Subscriber\ArgumentMetadata` no longer carries a `string $type`
127+
and a `bool $allowsNull` property. Instead it now has a single `Symfony\Component\TypeInfo\Type $type` property.
128+
129+
If you implemented a custom `ArgumentResolver`, adjust it to read the type from the new `Type` object.
130+
89131
## Store
90132

91133
### StreamStore
@@ -106,6 +148,49 @@ And all the associated classes:
106148

107149
`StreamReadOnlyStore` was been merged in `ReadOnlyStore`.
108150

151+
## Stream
152+
153+
The stream handling has been reworked. Previously the `Stream` was an interface that every store had to
154+
implement on its own (`ArrayStream`, `StreamDoctrineDbalStoreStream`, `TaggableDoctrineDbalStoreStream`,
155+
`GeneratorStream`, ...). Now there is a single generic implementation that you can reuse.
156+
157+
### Stream interface
158+
159+
The `Patchlevel\EventSourcing\Store\Stream` interface has been removed and replaced by the concrete final
160+
class `Patchlevel\EventSourcing\Message\Stream`.
161+
162+
All stores now return a `Patchlevel\EventSourcing\Message\Stream` from their `load()` method.
163+
The following store specific stream implementations have been removed:
164+
165+
* `Patchlevel\EventSourcing\Store\ArrayStream`
166+
* `Patchlevel\EventSourcing\Store\StreamDoctrineDbalStoreStream`
167+
* `Patchlevel\EventSourcing\Store\TaggableDoctrineDbalStoreStream`
168+
* `Patchlevel\EventSourcing\Subscription\Engine\GeneratorStream`
169+
170+
The new `Stream` class implements `Iterator` and accepts any `iterable<Message>` in its constructor.
171+
The `index()`, `position()`, `end()` and `close()` methods remain available.
172+
In addition there are now the helper methods `toList()`, `toArray()`, `transform()` and `chunk()`.
173+
174+
### Pipe
175+
176+
`Patchlevel\EventSourcing\Message\Pipe` has been removed. Use `Stream::transform()` instead.
177+
178+
before:
179+
180+
```php
181+
use Patchlevel\EventSourcing\Message\Pipe;
182+
183+
$messages = (new Pipe($messages, $translator))->toArray();
184+
```
185+
186+
after:
187+
188+
```php
189+
use Patchlevel\EventSourcing\Message\Stream;
190+
191+
$messages = (new Stream($messages))->transform($translator)->toList();
192+
```
193+
109194
## Message
110195

111196
### AggregateHeader

docs/message.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,33 @@ use Patchlevel\EventSourcing\Message\Message;
9797
/** @var Message $message */
9898
$message->header(ApplicationHeader::class);
9999
```
100-
## Pipe
100+
## Stream
101101

102-
The `Pipe` is a construct that allows you to chain multiple translators.
102+
A `Stream` wraps an iterable of messages and allows you to chain multiple translators with `transform`.
103103
This can be used to manipulate, filter or expand messages or events.
104104
This can be used for anti-corruption layers, data migration, or to fix errors in the event stream.
105105

106106
```php
107-
use Patchlevel\EventSourcing\Message\Pipe;
107+
use Patchlevel\EventSourcing\Message\Stream;
108108
use Patchlevel\EventSourcing\Message\Translator\ExcludeEventTranslator;
109109
use Patchlevel\EventSourcing\Message\Translator\RecalculatePlayheadTranslator;
110110

111-
$messages = new Pipe(
112-
$messages,
111+
$stream = (new Stream($messages))->transform(
113112
new ExcludeEventTranslator([ProfileCreated::class]),
114113
new RecalculatePlayheadTranslator(),
115114
);
116115

117-
foreach ($messages as $message) {
116+
foreach ($stream as $message) {
118117
// do something with the message
119118
}
120119
```
120+
121+
:::tip
122+
A `Stream` is also what every store returns from its `load` method, so you can apply the same
123+
transformations to the messages you read from the store. Besides iterating, a `Stream` offers
124+
`toList()`, `toArray()` and `chunk()` to consume the messages.
125+
:::
126+
121127
## Translator
122128

123129
Translator can be used to manipulate, filter or expand messages or events.

0 commit comments

Comments
 (0)