EventFlow
EventFlow copied to clipboard
Load aggregate at specific version
Hi !
In our company we are starting to use Eventflow.
We have a use case where we want to query the state of our aggregate between date range.
So far I did not see any out of the box way to do that. Did I miss something or did not understand a concept?
I think that I should use the event store and load all events for my aggregate then replay them until the desired date however I can foresee performance issue at some point.
This is where I may use snapshot,
However I did not see a way to query a snapshot from a certain date...
Do you have any advice concerning this use case?
Regards
Ayrton
Hi @Athosone
Just to make sure that I fully understand, you want to read the aggregate as it looked at a specific point in time? If so, then no, there isn't anything currently in the framework. But sounds like a useful thing to have.
I looked into the current available APIs and doing it yourself doesn't seem complicated. Read the events from the aggregate you are interested in via the IEventStore
, do the required filtering, then create a new empty instance of your aggregate via the IAggregateFactory
and simply invoke ApplyEvents
with the list of filtered events on the aggregate.
Thanks for the quick reply
Ok then I'll experiment with this, we could contribute eventually if that's something that may interest you?
As for the snapshot I would need to implement a custom snapshot store which persist a new snapshot of the aggregate instead of updating the current one right ? using the timestamp / id as index
I have a similar need, so if it's something you want in EventFlow, I can fork and PR it for you. I would also be interested in helping contribute to the project, we are ramping up to use it here at my company. So let me know if you'd be interested in that as well.
@Athosone did you see https://github.com/eventflow/EventFlow/issues/570
Something like
// Load events representing version
var domainEvents = IEventStore.LoadEventsAsync(id)
domainEvents = domainEvents.Where(e => e.AggregateSequenceNumber < selected version).ToList()
// Apply to empty aggregate
var aggregate = IAggregateFactory.CreateNewAggregateAsync(id)
aggregate.ApplyEvents(domainEvents)
Hello there!
We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days. We consider this issue to be stale and will be closing it within the next seven days.
If you still require assistance with this issue, please feel free to reopen it or create a new issue.
Thank you for your understanding and cooperation.
Best regards, EventFlow
Hello there!
We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days. We consider this issue to be stale and will be closing it within the next seven days.
If you still require assistance with this issue, please feel free to reopen it or create a new issue.
Thank you for your understanding and cooperation.
Best regards, EventFlow
Will make it respect the stale exempt