Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer Event (de)normalization #241

Open
bwaidelich opened this issue Nov 5, 2019 · 3 comments
Open

Defer Event (de)normalization #241

bwaidelich opened this issue Nov 5, 2019 · 3 comments

Comments

@bwaidelich
Copy link
Member

Currently events are converted to an EventEnvelope instance (with RawEvent and the denormalized DomainEventInterface instance) when iterating an event stream.

Instead the denormalization should only happen when actually required (i.e. when invoking the corresponding when*() method).

@bwaidelich
Copy link
Member Author

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)

@bwaidelich
Copy link
Member Author

As for the reasoning:

  • Increase performance
  • Allow Event Store part to be used for different (low level) purposes that don't require Domain Event instances
  • Simplify ES code

@bwaidelich
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant