Open bwaidelich opened 4 years ago
Some more thoughts I had on this one:
IMO the notion of DomainEvent
should be removed completely from the Event Store "sub package" so that it can be simplified to sth like:
final class Event {
public function __construct(string $identifier, string $type, array $data, array $metadata)
}
(currently WriteableEvent
)
when committing events, and:
final class EventEnvelope {
public function __construct(Event $event, StreamName $streamName, int $version, int $sequenceNumber, \DateTimeInterface $recordedAt)
}
when reading events.
The conversion from and to DomainEventInterface
instances would happen outside of the Event Store part (and only as soon as required, if at all)
As for the reasoning:
An additional reason:
It's a major design flaw that EventStorageInterface::load() returns an EventStream (https://github.com/neos/Neos.EventSourcing/blob/master/Classes/EventStore/Storage/EventStorageInterface.php#L32) since the event stream requires an instance of the EventNormalizer (https://github.com/neos/Neos.EventSourcing/blob/master/Classes/EventStore/EventStream.php#L43)
=> for custom event type converters etc. we always have to create a dedicated EventStorage instance and the factory won't support that out of the box
Currently events are converted to an
EventEnvelope
instance (withRawEvent
and the denormalizedDomainEventInterface
instance) when iterating an event stream.Instead the denormalization should only happen when actually required (i.e. when invoking the corresponding
when*()
method).