Hi,
Hope I'm not taking liberties by bombarding you with questions at the moment!
In the akka-persistence docs, there's an example of EventsourcedProcessor showing a basic implementation. It's up to the implementor to implement receiveReplay() and receiveCommand(). It's interesting that the concept of recovering from a snapshot is concrete in the API whereas triggering a snapshot to be saved is the responsibility of the implementor. This is sort of okay because it's not always true that implementors will want to use snapshots - thus it shouldn't be enforced. Also, even when using snapshots, the application will probably want to decide on snapshot scheduling (although they may want to configure this outside of the code - see below).
The thing that sort of sticks out in the example code is the use of become/unbecome. The actor, therefore, switches it's receive loop such that it does not handle a save snapshot message (until a further message received triggers unbecome). This kind of feels a bit weird. I suppose it's feasible that an actor, when in some specific state, may not wish to save a snapshot, but that might be an edge case. Am I being pedantic to suggest that the triggering of snapshot persistence could somehow become more transparent to the implementor?
My reason for asking is that this has come up in the side project I'm working on. In that case, snapshot persistence will be integrated into the framework and I don't want to burden the implementor with having to worry about it - ideally they'd be able to use features like become/unbecome without needing to even think about snapshot persistence (other than providing a way to expose current state). Possibly they'd configure snapshot persistence via app config - I want aggregate roots (actors) to focus as much as possible on just business logic rather than persistence concerns. I can think of some workarounds - and maybe this is just the nature of building an abstraction layer over the top of akka-persistence - but I'm interested to see whether you might agree with my observation.
Maybe this is more a question about patterns for working with become/unbecome where all potential states share some common message handling logic?
Andrew