akkadotnet / akka.net

Canonical actor model implementation for .NET with local + distributed actors in C# and F#.
http://getakka.net
Other
4.71k stars 1.04k forks source link

Docs: need to mention SaveSnapshot state must be passed in immutable manner #5058

Open christallire opened 3 years ago

christallire commented 3 years ago

Please describe what you are trying to understand I recently went through exactly same issue with https://github.com/akkadotnet/akka.net/issues/4451 and I did exactly what he did. I even looked through JVM document and sources.

Which pages have you looked at? https://getakka.net/articles/persistence/snapshots.html

What did these pages not make clear? in classic Akka all messages must be immutable, and since you are putting your state inside a message (SaveSnapshot), then it needs to be immutable as well.

How can we do it better? Please mention this in the doc

Additional suggestions I'm not sure why both https://doc.akka.io/docs/akka/current/persistence.html and https://getakka.net/articles/persistence/snapshots.html not mentioning anything about immutable -- is there any chance that the JVM does it implicitly?

Aaronontheweb commented 3 years ago

@christallire the JVM doesn't necessarily do it implicitly - case classes and other types of objects can be immutable, but since it's user-land data types that end up in snapshots it's incumbent upon the user to take care of this.