Example #1
0
 /// <summary>
 /// Initial state. Before starting the actual recovery it must get a permit from the `RecoveryPermitter`.
 /// When starting many persistent actors at the same time the journal and its data store is protected from
 /// being overloaded by limiting number of recoveries that can be in progress at the same time.
 /// When receiving `RecoveryPermitGranted` it switches to `recoveryStarted` state.
 /// All incoming messages are stashed.
 /// </summary>
 private EventsourcedState WaitingRecoveryPermit(Recovery recovery)
 {
     return(new EventsourcedState("waiting for recovery permit", () => true, (receive, message) =>
     {
         if (message is RecoveryPermitGranted)
         {
             StartRecovery(recovery);
         }
         else
         {
             StashInternally(message);
         }
     }));
 }
 private void StartRecovery(Recovery recovery)
 {
     ChangeState(RecoveryStarted(recovery.ReplayMax));
     LoadSnapshot(SnapshotterId, recovery.FromSnapshot, recovery.ToSequenceNr);
 }