public async Task InitAsync(IProvider provider, IContext context, IPersistentActor actor) { _state = provider.GetState(); _context = context; _actor = actor; var(snapshot, index) = await _state.GetSnapshotAsync(ActorId); if (snapshot != null) { Index = index; _actor.UpdateState(new RecoverSnapshot(snapshot, index)); } ; await _state.GetEventsAsync(ActorId, Index, @event => { Index++; _actor.UpdateState(new RecoverEvent(@event, Index)); }); }
// allow passing in of IProviderState to allow state to "persist" across actor restarts public InMemoryProvider(InMemoryProviderState state = null) { _state = state; }