public async Task PersistEventAsync(object @event) { if (!UsingEventSourcing) { throw new Exception("Event cannot be persisted without using Event Sourcing."); } Index++; await _provider.PersistEventAsync(_actorId, Index, @event); var persistedEvent = new PersistedEvent(@event, Index); _applyEvent(persistedEvent); if (_snapshotStrategy.ShouldTakeSnapshot(persistedEvent)) { await _provider.PersistSnapshotAsync(_actorId, Index, _getState()); } }
public async Task PersistEventAsync(object @event) { if (!UsingEventSourcing) { throw new Exception("Event cannot be persisted without using Event Sourcing."); } var persistedEvent = new PersistedEvent(@event, (Index + 1)); await _eventStore.PersistEventAsync(_actorId, persistedEvent.Index, persistedEvent.Data); Index++; _applyEvent(persistedEvent); if (_snapshotStrategy.ShouldTakeSnapshot(persistedEvent)) { var persistedSnapshot = new PersistedSnapshot(_getState(), persistedEvent.Index); await _snapshotStore.PersistSnapshotAsync(_actorId, persistedSnapshot.Index, persistedSnapshot.State); } }
public bool ShouldTakeSnapshot(PersistedEvent persistedEvent) { return(false); }
public bool ShouldTakeSnapshot(PersistedEvent persistedEvent) => false;