core-java
core-java copied to clipboard
`recentHistory()` for event sourced `Entity` implementations
Aggregate
and other entities, which state is built from events, do not provide any way to fetch the recent history of events. However, this can be extremely helpful in some business scenarios.
In scope of this feature we'll need to provide an API, which will be available for usage to Aggregate
descendants — i.e. to those who implement their own command handlers, event reactors and event appliers.
In scope of this feature the simplest and the most high-performant implementation should be created. I.e. recentHistory() : Iterable<Message>
will return Event
instances and the most recent Snapshot
instance (if any).
The idea behind this is that the repository loads these pieces of data anyway, so they can be exposed at no cost.
In future this API may be extended to allow loading the next portion of events (e.g. look deeper into the history). However, as that most certainly will require an additional call, it is not a subject of this particular feature request.