private async Task <bool> ProcessEventsAsync(long?lastCommitPosition, AllEventsSlice slice) { foreach (var e in slice.Events) { if (e.OriginalPosition == null) { throw new Exception(String.Format("Subscription {0} event came up with no OriginalPosition.", SubscriptionName)); } await TryProcessAsync(e).ConfigureAwait(false); } await ProcessClientSideCheckpointReached(slice.NextPosition); _nextReadPosition = slice.NextPosition; var done = lastCommitPosition == null ? slice.IsEndOfStream : slice.NextPosition >= new Position(lastCommitPosition.Value, lastCommitPosition.Value); if (!done && slice.IsEndOfStream) { await Task.Delay(1).ConfigureAwait(false); // we are awaiting the server to flush its data } return(done); }
/// <summary> /// Read events until the given position. /// </summary> /// <param name="connection">The connection.</param> /// <param name="resolveLinkTos">Whether to resolve Link events.</param> /// <param name="userCredentials">User credentials for the operation.</param> /// <param name="lastCommitPosition">The commit position to read until.</param> /// <param name="lastEventNumber">The event number to read until.</param> protected override void ReadEventsTill(IEventStoreConnection connection, bool resolveLinkTos, UserCredentials userCredentials, long?lastCommitPosition, int?lastEventNumber) { bool done; do { AllEventsSlice slice = connection.ReadAllEventsForwardAsync(_nextReadPosition, ReadBatchSize, resolveLinkTos, userCredentials).Result; foreach (var e in slice.Events) { if (e.OriginalPosition == null) { throw new Exception("Subscription event came up with no OriginalPosition."); } TryProcess(e); } _nextReadPosition = slice.NextPosition; done = lastCommitPosition == null ? slice.IsEndOfStream : slice.NextPosition >= new Position(lastCommitPosition.Value, lastCommitPosition.Value); if (!done && slice.IsEndOfStream) { Thread.Sleep(1); // we are waiting for server to flush its data } } while (!done && !ShouldStop); if (Verbose) { Log.Debug("Catch-up Subscription to {0}: finished reading events, nextReadPosition = {1}.", IsSubscribedToAll ? "<all>" : StreamId, _nextReadPosition); } }
private async Task <bool> ReadEventsCallbackAsync(AllEventsSlice slice, long?lastCommitPosition) { bool shouldStopOrDone = ShouldStop || await ProcessEventsAsync(lastCommitPosition, slice).ConfigureAwait(false); if (shouldStopOrDone && Verbose) { Log.Debug( "Catch-up Subscription {0} to {1}: finished reading events, nextReadPosition = {2}.", SubscriptionName, IsSubscribedToAll ? "<all>" : StreamId, _nextReadPosition); } return(shouldStopOrDone); }
private async Task ReadEventsCallbackAsync(AllEventsSlice slice, IEventStoreConnection connection, bool resolveLinkTos, UserCredentials userCredentials, long?lastCommitPosition, long?lastEventNumber) { if (!(await ProcessEventsAsync(lastCommitPosition, slice).ConfigureAwait(false)) && !ShouldStop) { await ReadEventsInternalAsync(connection, resolveLinkTos, userCredentials, lastCommitPosition, lastEventNumber).ConfigureAwait(false); } else { if (Verbose) { Log.Debug( "Catch-up Subscription {0} to {1}: finished reading events, nextReadPosition = {2}.", SubscriptionName, IsSubscribedToAll ? "<all>" : StreamId, _nextReadPosition); } } }
private bool ProcessEvents(long?lastCommitPosition, AllEventsSlice slice) { foreach (var e in slice.Events) { if (e.OriginalPosition == null) { throw new Exception("Subscription event came up with no OriginalPosition."); } TryProcess(e); } _nextReadPosition = slice.NextPosition; var done = lastCommitPosition == null ? slice.IsEndOfStream : slice.NextPosition >= new Position(lastCommitPosition.Value, lastCommitPosition.Value); if (!done && slice.IsEndOfStream) { Thread.Sleep(1); // we are waiting for server to flush its data } return(done); }
private bool ProcessEvents(long? lastCommitPosition, AllEventsSlice slice) { foreach (var e in slice.Events) { if (e.OriginalPosition == null) throw new Exception("Subscription event came up with no OriginalPosition."); TryProcess(e); } _nextReadPosition = slice.NextPosition; var done = lastCommitPosition == null ? slice.IsEndOfStream : slice.NextPosition >= new Position(lastCommitPosition.Value, lastCommitPosition.Value); if (!done && slice.IsEndOfStream) Thread.Sleep(1); // we are waiting for server to flush its data return done; }
private void DisplayTfScanProgress(AllEventsSlice slice) { if (slice.Events.Length > 0) { var percent = Math.Round( (float) slice.Events[slice.Events.Length - 1].OriginalPosition.Value.PreparePosition/_lastTfPosition*100); if (percent != _oldTfScanPercent) { _oldTfScanPercent = percent; Console.WriteLine("{0,2}% completed.", percent); } } }