Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API for reading the latest version of an aggregate. Read-only version of FetchForWriting() #3581

Closed
jeremydmiller opened this issue Dec 9, 2024 · 1 comment

Comments

@jeremydmiller
Copy link
Member

As a companion to JasperFx/wolverine#1161.

Let's say that you use FetchForWriting() in a command, then immediately want the latest state for whatever the "T" aggregate was as the response in a command. We could use a read only version of FetchForWriting() that tries the most effeciently way possible to get you the current status of the "T" after SaveChangesAsync() is called.

Some notes:

  • API could be IDocumentSession.Events.FetchLatestAsync<T>()
  • If the projection is Inline, try to pluck it from the identity map. You'd have this if the identity map is enabled for the session, or you use the optimization for opting into the identity map for aggregations
  • In the case of live aggregations, have FetchForWriting() add the fetched version to the identity map. FetchForLatestAsync() could use that as a starting point, then apply the events from the StreamAction in history of the session to build the latest
  • In the case of async, try to have FetchForWriting() stash the starting point of the aggregate in the identity map. Maybe, try to first use the events appended on top of the initial version fetched?? Otherwise, fetch from db normally
@jeremydmiller
Copy link
Member Author

First pass is "done", now on to customizations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant