Пример #1
0
        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());
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
 public bool ShouldTakeSnapshot(PersistedEvent persistedEvent)
 {
     return(false);
 }
Пример #4
0
 public bool ShouldTakeSnapshot(PersistedEvent persistedEvent) => false;