private async Task <List <PartitionKeyRange> > EnumPartitionKeyRangesAsync()
        {
            string containerUri           = this.container.LinkUri.ToString();
            string partitionKeyRangesPath = string.Format(CultureInfo.InvariantCulture, "{0}/pkranges", containerUri);

            IFeedResponse <PartitionKeyRange> response           = null;
            List <PartitionKeyRange>          partitionKeyRanges = new List <PartitionKeyRange>();

            do
            {
                FeedOptions feedOptions = new FeedOptions
                {
                    MaxItemCount        = this.maxBatchSize,
                    RequestContinuation = response?.ResponseContinuation,
                };

                response = await this.container.ClientContext.DocumentClient.ReadPartitionKeyRangeFeedAsync(containerUri, feedOptions).ConfigureAwait(false);

                IEnumerator <PartitionKeyRange> enumerator = response.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    partitionKeyRanges.Add(enumerator.Current);
                }
            }while (!string.IsNullOrEmpty(response.ResponseContinuation));

            return(partitionKeyRanges);
        }
Exemple #2
0
        private static Document GetFirstDocument(IFeedResponse <Document> response)
        {
            using (IEnumerator <Document> e = response.GetEnumerator())
            {
                while (e.MoveNext())
                {
                    return(e.Current);
                }
            }

            return(null);
        }
        private Task DispatchChanges(IFeedResponse <Document> response, CancellationToken cancellationToken)
        {
            IChangeFeedObserverContext context = new ChangeFeedObserverContext(this.settings.PartitionKeyRangeId, response, this.checkpointer);
            var docs = new List <Document>(response.Count);

            using (IEnumerator <Document> e = response.GetEnumerator())
            {
                while (e.MoveNext())
                {
                    docs.Add(e.Current);
                }
            }

            return(this.observer.ProcessChangesAsync(context, docs, cancellationToken));
        }
        private Task DispatchChanges(IFeedResponse <T> response, CancellationToken cancellationToken)
        {
            ChangeFeedObserverContext context = new ChangeFeedObserverContextCore <T>(this.settings.LeaseToken, response, this.checkpointer);
            List <T> docs = new List <T>(response.Count);

            using (IEnumerator <T> e = response.GetEnumerator())
            {
                while (e.MoveNext())
                {
                    docs.Add(e.Current);
                }
            }

            return(this.observer.ProcessChangesAsync(context, docs, cancellationToken));
        }