ThreeDotsLabs / esja

Event Sourcing library in Go.
MIT License
19 stars 4 forks source link

Improve transport.Event definition #24

Closed krzysztofreczek closed 1 year ago

krzysztofreczek commented 1 year ago

Why? Previously DefaultMapper was using the following logic to register supported transport.Events in the constructor:

supported := map[stream.EventName]Event[T]{}
for _, e := range supportedEvents {
  supported[e.ToStreamEvent().EventName()] = e
}

In case when the invocation of the method ToStreamEvent() on empty events was not possible - it could panic as an empty event is not an expected state usually for events - the entire repository construction was panicking.

What? Now each transport.Event must provide a method returning the name of an event it corresponds to.

Tests As the behavior should not change the existing tests already cover that. Only the _example events were adjusted to the modified interface.