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

Support mutable state in PersistentBehavior #25740

Closed
patriknw opened this Issue Oct 4, 2018 · 0 comments

Comments

Projects
1 participant
@patriknw
Copy link
Member

commented Oct 4, 2018

The reason we only support immutable state is that it is stored as snapshot asynchronously.

For Java it's cumbersome to be strictly immutable, and less familiar.

The builders for event and command dispatch work fine when defined outside the State, but if we want to support a ADT style where the actual logic of how to apply the events is defined in the concrete State classes. Due to lack of pattern matching in Java we would have to use builders for matching on the events, but creating a new builder for each invocation seems very wasteful and contradicts the idea that a builder is created once to construct the function, which is then invoked many times.
By allowing mutable State classes the builder can be used inside the state class.

Two solutions were suggested:

  • don't process any new commands while snapshotting is in progress (like for events), possibility to opt-out if state is immutable
  • serialize before sending to snapshot store

Some experiments in #25729

@patriknw patriknw added this to Backlog in Akka Typed Oct 15, 2018

@patriknw patriknw moved this from Backlog to Ready for production backlog in Akka Typed Dec 11, 2018

@patriknw patriknw self-assigned this Jan 21, 2019

@patriknw patriknw moved this from Ready for production backlog to In Progress in Akka Typed Jan 21, 2019

patriknw added a commit that referenced this issue Jan 21, 2019

patriknw added a commit that referenced this issue Jan 21, 2019

patriknw added a commit that referenced this issue Jan 28, 2019

@johanandren johanandren moved this from In Progress to Reviewing in Akka Typed Feb 1, 2019

patriknw added a commit that referenced this issue Feb 22, 2019

@patriknw patriknw added this to the 2.5.22 milestone Feb 22, 2019

@patriknw patriknw closed this Feb 22, 2019

Akka Typed automation moved this from Reviewing to Done Feb 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.