eventhorizon icon indicating copy to clipboard operation
eventhorizon copied to clipboard

[eventstore] Replay events (or load history by provided array)

Open samueledirito opened this issue 8 years ago • 10 comments

Have you already implemented a way to replay events or passing history events array as a ctor argument? Sometimes it is very useful.

TIA

samueledirito avatar Jan 24 '17 09:01 samueledirito

I have it planned but not yet noted as an issue, thanks for bringing it up!

It will definitely be crucial for the toolkit!

maxekman avatar Jan 24 '17 11:01 maxekman

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 avatar Jan 24 '17 11:01 maxekman

@maxekman Thank you very much, it's exactly what i'm looking for.

samueledirito avatar Jan 24 '17 11:01 samueledirito

I'll keep this open for the real implementation.

maxekman avatar Jan 24 '17 11:01 maxekman

so for the current version, I have to replay all events to reflect the most updated state after server restart? Thanks.

dantetwc avatar Apr 10 '17 09:04 dantetwc

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.

maxekman avatar Apr 10 '17 13:04 maxekman

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.

toesterdahl avatar May 22 '19 11:05 toesterdahl

Really cool, I’ll check it out in detail as soon as I can!

maxekman avatar May 22 '19 13:05 maxekman

@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 avatar Apr 12 '20 16:04 maxruby

@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.

maxekman avatar Apr 29 '20 11:04 maxekman