Пример #1
0
        private async Task <Page> TryGetNextPage(long checkpoint)
        {
            Page page = null;

            try
            {
#if DEBUG
                LogProvider.GetLogger(typeof(Subscription)).Debug(() =>
                                                                  $"Subscription {Id} is requesting a page after checkpoint {checkpoint}.");
#endif

                page = await eventStoreAdapter.GetNextPage(checkpoint, Id)
                       .WithWaitCancellation(cancellationTokenSource.Token)
                       .ConfigureAwait(false);

#if DEBUG
                LogProvider.GetLogger(typeof(Subscription)).Debug(() =>
                                                                  $"Subscription {Id} has got a page of size {page.Transactions.Count} " +
                                                                  $"from checkpoint {page.Transactions.First().Checkpoint} " +
                                                                  $"to checkpoint {page.Transactions.Last().Checkpoint}.");
#endif
            }
            catch
            {
                // Just continue the next iteration after a small pause
            }

            return(page);
        }
        private async Task <Page> TryGetNextPage(long checkpoint)
        {
            Page page = null;

            try
            {
                logger(() => $"Request Page (subscription: {id}, precedingCheckpoint: {checkpoint}).");

                page = await eventStoreAdapter.GetNextPage(checkpoint, id, cancellationTokenSource.Token)
                       .WithWaitCancellation(cancellationTokenSource.Token)
                       .ConfigureAwait(false);

                logger(() =>
                       $"Received Page (subscription: {id}, size: {page.Transactions.Count}, " +
                       $"range: {page.Transactions.First().Checkpoint}-{page.Transactions.Last().Checkpoint}.");
            }
            catch
            {
                // Just continue the next iteration after a small pause
            }

            return(page);
        }