public CheckpointProjection( IStatefulProjection inner, CheckpointStore checkpointStore, Action <AllStreamPosition> notifyCheckpoint = null) { _inner = inner; _checkpointStore = checkpointStore; _notifyCheckpoint = notifyCheckpoint; _lastCheckpoint = _checkpointStore.Read(); _notifyCheckpoint?.Invoke(AllStreamPosition.FromNullableInt64(_lastCheckpoint)); }
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)); } }
public AllStreamPosition ReadCheckpoint(string name) => _checkpointStores.TryGetValue(name, out CheckpointStore store) ? AllStreamPosition.FromNullableInt64(store.Read()) : AllStreamPosition.None;