eventhorizon
eventhorizon copied to clipboard
[eventstore] Replay events (or load history by provided array)
Have you already implemented a way to replay events or passing history events array as a ctor argument? Sometimes it is very useful.
TIA
I have it planned but not yet noted as an issue, thanks for bringing it up!
It will definitely be crucial for the toolkit!
If you want to do it manually for now you can mimmic how the repository does it: https://github.com/looplab/eventhorizon/blob/master/repository.go#L68
@maxekman Thank you very much, it's exactly what i'm looking for.
I'll keep this open for the real implementation.
so for the current version, I have to replay all events to reflect the most updated state after server restart? Thanks.
Yes, if you don't use projections you have to replay all events. I'm sure you have looked at the examples for two ways to do projections, if not take a look. When running commands on an aggregate with the EventSourcingRepository it will currently always build the aggregate by loading all events. Snapshotting is planned to be implemented at some point to make this more efficient, see #33.
Referring to my branch, https://github.com/toesterdahl/eventhorizon/tree/initprojector initprojector demonstrate how to be able to 'restore' a projector from an existing event stream. Since this is operations on the eventstore side of things, yet serving the projektions, I added a new entity, the 'projectorManager'. So far projectorManager have a single method 'restore'. There is the 'weatherstation' example utilizing the restore. Possible use-cases
- Creating another Client instance.
- Creating a new Projector to track an existing Aggregate. Apart from 'restore' I would consider adding methods to the projectorManager for restoring from a particular version (fast-forward). I am interested in feedback on this approach.
Really cool, I’ll check it out in detail as soon as I can!
@maxekman
First of all great work on this nice library.
I am rather new to EH and its internal details (though I have experience with a full CQRS/ES implementation in our company which uses PHP). I am wondering whether you think the Restore
implementation from @toesterdahl could be in any way integrated into EH?
On a separate topic (apologies for deviating from the primary topic here), how much active development is going on with EH? Are you still using it in production and are any others you know using it in production as well?
@maxruby I'll definitely look into it as I'm now back on working a bit more on EH for a client. That client have been using it in production since it's inception and has now quiet a bit of data going through it. EH was initially authored for that project.