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

EphemeralView implementation #338

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

DomenicDev
Copy link
Contributor

@DomenicDev DomenicDev commented Dec 11, 2024

This development implements the concept of an EphemeralView, a view that is built "on the fly" and not maintained/materialized. Potential use cases include:

  • Lightweight aggregation for ad-hoc analysis
  • Development and prototyping read models
  • Building strongly consistent read models
  • Supporting the "read your own rights" guarantee

The main algorithm is as follows:

suspend fun <S, E, Q, EV> EV.handle(query: Q): S where EV : ViewStateComputation<S, E>, EV : EphemeralViewRepository<E, Q> =
    query.fetchEvents().fold(initialState) { s, e -> evolve(s, e) }

Events of type E are fetched based on a query Q, which are then used to build the respective view IView<S, E>. The result of that computation S is returned to the caller.

@DomenicDev DomenicDev marked this pull request as draft December 13, 2024 16:16
Copy link
Member

@idugalic idugalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution @DomenicDev !

@DomenicDev DomenicDev changed the title MemoryView implementation EphemeralView implementation Dec 14, 2024
@DomenicDev DomenicDev marked this pull request as ready for review December 14, 2024 15:12
@idugalic idugalic merged commit c417ca8 into fraktalio:main Dec 14, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants