public async ValueTask <bool> MoveNextAsync() { ReadLoop: if (_disposedTokenSource.IsCancellationRequested) { return(false); } if (_buffer.TryDequeue(out var current)) { _current = current; _currentPosition = Position.FromInt64(current.OriginalPosition.Value.CommitPosition, current.OriginalPosition.Value.PreparePosition); return(true); } var correlationId = Guid.NewGuid(); var readNextSource = new TaskCompletionSource <bool>(); var(commitPosition, preparePosition) = _nextPosition.ToInt64(); Log.Verbose( "Catch-up subscription {subscriptionId} to $all:{eventFilter} reading next page starting from {nextPosition}.", _subscriptionId, _eventFilter, _nextPosition); _bus.Publish(new ClientMessage.FilteredReadAllEventsForward( correlationId, correlationId, new CallbackEnvelope(OnMessage), commitPosition, preparePosition, ReadBatchSize, _resolveLinks, false, (int)_maxWindowSize, default, _eventFilter, _user));
private void ReadPage(Position position, Func <Message, CancellationToken, Task> onMessage) { Guid correlationId = Guid.NewGuid(); Log.Verbose( "Subscription {subscriptionId} to $all:{eventFilter} reading next page starting from {nextRevision}.", _subscriptionId, _eventFilter, position); var(commitPosition, preparePosition) = position.ToInt64(); _bus.Publish(new ClientMessage.FilteredReadAllEventsForward( correlationId, correlationId, new ContinuationEnvelope(onMessage, _semaphore, _cancellationToken), commitPosition, preparePosition, ReadBatchSize, _resolveLinks, _requiresLeader, (int)_maxSearchWindow, default, _eventFilter, _user));