Esempio n. 1
0
 public abstract FeedIterator GetStandByFeedIterator(
     string continuationToken = default,
     int?maxItemCount         = default,
     ChangeFeedRequestOptions requestOptions = default);
Esempio n. 2
0
 public abstract FeedIterator <T> GetChangeFeedIterator <T>(
     FeedRange feedRange,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
Esempio n. 3
0
 public abstract FeedIterator <T> GetChangeFeedIterator <T>(
     PartitionKey partitionKey,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
 internal abstract FeedIterator GetStandByFeedIterator(
     ChangeFeedRequestOptions requestOptions = default);
Esempio n. 5
0
 public abstract FeedIterator <T> GetChangeFeedIterator <T>(
     string continuationToken = null,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
Esempio n. 6
0
 FeedIterator GetChangeFeedStreamIterator(ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(new ChangeFeedIteratorCore(
                this,
                changeFeedRequestOptions));
 }
 public override FeedIterator GetChangeFeedStreamIterator(
     PartitionKey partitionKey,
     ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(this.container.GetChangeFeedStreamIterator(partitionKey, changeFeedRequestOptions));
 }
 public abstract FeedIterator GetChangeFeedStreamIterator(
     ChangeFeedStartFrom changeFeedStartFrom,
     ChangeFeedMode changeFeedMode,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
 public abstract FeedIterator <T> GetChangeFeedIterator <T>(
     ChangeFeedStartFrom changeFeedStartFrom,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
 public override FeedIterator <T> GetChangeFeedIterator <T>(
     ChangeFeedStartFrom changeFeedStartFrom,
     ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(this.GetChangeFeedIterator <T>(changeFeedStartFrom, ChangeFeedMode.Incremental, changeFeedRequestOptions));
 }
Esempio n. 11
0
        private async Task <ResponseMessage> ReadNextInternalAsync(
            CosmosDiagnosticsContext diagnosticsScope,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (this.feedTokenInternal == null)
            {
                Routing.PartitionKeyRangeCache partitionKeyRangeCache = await this.clientContext.DocumentClient.GetPartitionKeyRangeCacheAsync();

                string containerRId = await this.container.GetRIDAsync(cancellationToken);

                IReadOnlyList <Documents.PartitionKeyRange> partitionKeyRanges = await partitionKeyRangeCache.TryGetOverlappingRangesAsync(
                    containerRId,
                    new Documents.Routing.Range <string>(
                        Documents.Routing.PartitionKeyInternal.MinimumInclusiveEffectivePartitionKey,
                        Documents.Routing.PartitionKeyInternal.MaximumExclusiveEffectivePartitionKey,
                        isMinInclusive: true,
                        isMaxInclusive: false),
                    forceRefresh : true);

                // ReadAll scenario, initialize with one token for all
                this.feedTokenInternal = new FeedTokenEPKRange(containerRId, partitionKeyRanges);
            }

            Uri             resourceUri     = this.container.LinkUri;
            ResponseMessage responseMessage = await this.clientContext.ProcessResourceOperationStreamAsync(
                resourceUri : resourceUri,
                resourceType : Documents.ResourceType.Document,
                operationType : Documents.OperationType.ReadFeed,
                requestOptions : this.changeFeedOptions,
                cosmosContainerCore : this.container,
                requestEnricher : request =>
            {
                ChangeFeedRequestOptions.FillContinuationToken(request, this.feedTokenInternal.GetContinuation());
                this.feedTokenInternal.EnrichRequest(request);
            },
                partitionKey : null,
                streamPayload : null,
                diagnosticsScope : diagnosticsScope,
                cancellationToken : cancellationToken);

            // Retry in case of splits or other scenarios
            if (await this.feedTokenInternal.ShouldRetryAsync(this.container, responseMessage, cancellationToken))
            {
                if (responseMessage.IsSuccessStatusCode ||
                    responseMessage.StatusCode == HttpStatusCode.NotModified)
                {
                    // Change Feed read uses Etag for continuation
                    this.feedTokenInternal.UpdateContinuation(responseMessage.Headers.ETag);
                }

                return(await this.ReadNextInternalAsync(diagnosticsScope, cancellationToken));
            }

            if (responseMessage.IsSuccessStatusCode ||
                responseMessage.StatusCode == HttpStatusCode.NotModified)
            {
                // Change Feed read uses Etag for continuation
                this.feedTokenInternal.UpdateContinuation(responseMessage.Headers.ETag);
            }

            this.hasMoreResults = responseMessage.IsSuccessStatusCode;
            return(responseMessage);
        }
Esempio n. 12
0
 public override FeedIterator <T> GetChangeFeedIterator <T>(
     PartitionKey partitionKey,
     ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(base.GetChangeFeedIterator <T>(partitionKey, changeFeedRequestOptions));
 }
Esempio n. 13
0
 public override FeedIterator <T> GetChangeFeedIterator <T>(
     FeedRange feedRange,
     ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(base.GetChangeFeedIterator <T>(feedRange, changeFeedRequestOptions));
 }
Esempio n. 14
0
 public override FeedIterator <T> GetChangeFeedIterator <T>(
     string continuationToken = null,
     ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(base.GetChangeFeedIterator <T>(continuationToken, changeFeedRequestOptions));
 }
Esempio n. 15
0
 public override FeedIterator <T> GetChangeFeedIterator <T>(
     ChangeFeedStartFrom changeFeedStartFrom,
     ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(base.GetChangeFeedIterator <T>(changeFeedStartFrom, changeFeedRequestOptions));
 }
 public abstract IAsyncEnumerable <TryCatch <ChangeFeedPage> > GetChangeFeedAsyncEnumerable(
     ChangeFeedCrossFeedRangeState state,
     ChangeFeedMode changeFeedMode,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
Esempio n. 17
0
 public override IAsyncEnumerable <TryCatch <ChangeFeed.ChangeFeedPage> > GetChangeFeedAsyncEnumerable(
     ChangeFeedCrossFeedRangeState state,
     ChangeFeedRequestOptions changeFeedRequestOptions = default)
 {
     return(base.GetChangeFeedAsyncEnumerable(state, changeFeedRequestOptions));
 }
Esempio n. 18
0
 public abstract FeedIterator GetChangeFeedStreamIterator(
     FeedRange feedRange,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
 public override FeedIterator GetChangeFeedStreamIterator(ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(this.container.GetChangeFeedStreamIterator(changeFeedRequestOptions));
 }
Esempio n. 20
0
 public abstract FeedIterator GetChangeFeedStreamIterator(
     PartitionKey partitionKey,
     ChangeFeedRequestOptions changeFeedRequestOptions = null);
 public override FeedIterator <T> GetChangeFeedIterator <T>(
     FeedToken feedToken,
     ChangeFeedRequestOptions changeFeedRequestOptions = null)
 {
     return(this.container.GetChangeFeedIterator <T>(feedToken, changeFeedRequestOptions));
 }
        private async Task <ResponseMessage> ReadNextInternalAsync(
            CosmosDiagnosticsContext diagnosticsScope,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (this.feedTokenInternal == null)
            {
                TryCatch <FeedTokenInternal> tryCatchFeedTokeninternal = await this.TryInitializeFeedTokenAsync(cancellationToken);

                if (!tryCatchFeedTokeninternal.Succeeded)
                {
                    if (tryCatchFeedTokeninternal.Exception.InnerException is CosmosException cosmosException)
                    {
                        return(cosmosException.ToCosmosResponseMessage(new RequestMessage(method: null, requestUri: null, diagnosticsContext: diagnosticsScope)));
                    }

                    return(CosmosExceptionFactory.CreateInternalServerErrorException(
                               message: tryCatchFeedTokeninternal.Exception.InnerException.Message,
                               innerException: tryCatchFeedTokeninternal.Exception.InnerException,
                               diagnosticsContext: diagnosticsScope).ToCosmosResponseMessage(new RequestMessage(method: null, requestUri: null, diagnosticsContext: diagnosticsScope)));
                }

                this.feedTokenInternal = tryCatchFeedTokeninternal.Result;
            }

            Uri             resourceUri     = this.container.LinkUri;
            ResponseMessage responseMessage = await this.clientContext.ProcessResourceOperationStreamAsync(
                resourceUri : resourceUri,
                resourceType : Documents.ResourceType.Document,
                operationType : Documents.OperationType.ReadFeed,
                requestOptions : this.changeFeedOptions,
                cosmosContainerCore : this.container,
                requestEnricher : request =>
            {
                ChangeFeedRequestOptions.FillContinuationToken(request, this.feedTokenInternal.GetContinuation());
                this.feedTokenInternal.EnrichRequest(request);
            },
                partitionKey : null,
                streamPayload : null,
                diagnosticsContext : diagnosticsScope,
                cancellationToken : cancellationToken);

            // Retry in case of splits or other scenarios
            if (await this.feedTokenInternal.ShouldRetryAsync(this.container, responseMessage, cancellationToken))
            {
                if (responseMessage.IsSuccessStatusCode ||
                    responseMessage.StatusCode == HttpStatusCode.NotModified)
                {
                    // Change Feed read uses Etag for continuation
                    this.feedTokenInternal.UpdateContinuation(responseMessage.Headers.ETag);
                }

                return(await this.ReadNextInternalAsync(diagnosticsScope, cancellationToken));
            }

            if (responseMessage.IsSuccessStatusCode ||
                responseMessage.StatusCode == HttpStatusCode.NotModified)
            {
                // Change Feed read uses Etag for continuation
                this.feedTokenInternal.UpdateContinuation(responseMessage.Headers.ETag);
            }

            this.hasMoreResults = responseMessage.IsSuccessStatusCode;
            return(responseMessage);
        }