public PersistBySnapshotTestActor() { _state = new TestActorState(); Recover <SnapshotOffer>(offer => { _log.Info("SnapshotOffer received."); _state = offer.Snapshot as TestActorState; }); Command <SetStateCommand>(cmd => { _state.State = cmd.NewState; SaveSnapshot(_state); }); Command <GetStateCommand>(cmd => { Sender.Tell(_state.State); }); }
public PersistByJournalTestActor() { _state = new TestActorState(); Recover <SetStateCommand>(cmd => { _log.Info("Recovering SetStateCommand."); _state.State = cmd.NewState; }); Recover <SnapshotOffer>(offer => { _log.Info("SnapshotOffer received."); _state = offer.Snapshot as TestActorState; }); Command <SetStateCommand>(cmd => { Persist(cmd, action => { _state.State = cmd.NewState; }); }); Command <GetStateCommand>(cmd => { Sender.Tell(_state.State); }); }