Exemple #1
0
        public CheckpointProjection(
            IStatefulProjection inner,
            CheckpointStore checkpointStore,
            Action <AllStreamPosition> notifyCheckpoint = null)
        {
            _inner            = inner;
            _checkpointStore  = checkpointStore;
            _notifyCheckpoint = notifyCheckpoint;

            _lastCheckpoint = _checkpointStore.Read();
            _notifyCheckpoint?.Invoke(AllStreamPosition.FromNullableInt64(_lastCheckpoint));
        }
Exemple #2
0
        public async Task Project(Envelope message, CancellationToken cancellationToken = default(CancellationToken))
        {
            var checkpoint = message.Checkpoint;

            if (_lastCheckpoint == null || checkpoint > _lastCheckpoint)
            {
                await _inner.Project(message, cancellationToken).ConfigureAwait(false);

                _lastCheckpoint = checkpoint;
                _notifyCheckpoint?.Invoke(AllStreamPosition.FromNullableInt64(_lastCheckpoint));
            }
        }
Exemple #3
0
 public AllStreamPosition ReadCheckpoint(string name) =>
 _checkpointStores.TryGetValue(name, out CheckpointStore store)
         ? AllStreamPosition.FromNullableInt64(store.Read())
         : AllStreamPosition.None;