internal virtual Task <ResponseMessage> NextResultSetDelegateAsync(
            string continuationToken,
            string partitionKeyRangeId,
            int?maxItemCount,
            ChangeFeedRequestOptions options,
            CancellationToken cancellationToken)
        {
            Uri resourceUri = this.container.LinkUri;

            return(this.clientContext.ProcessResourceOperationAsync <ResponseMessage>(
                       resourceUri: resourceUri,
                       resourceType: Documents.ResourceType.Document,
                       operationType: Documents.OperationType.ReadFeed,
                       requestOptions: options,
                       cosmosContainerCore: this.container,
                       requestEnricher: request =>
            {
                ChangeFeedRequestOptions.FillContinuationToken(request, continuationToken);
                ChangeFeedRequestOptions.FillMaxItemCount(request, maxItemCount);
                ChangeFeedRequestOptions.FillPartitionKeyRangeId(request, partitionKeyRangeId);
            },
                       responseCreator: response => response,
                       partitionKey: null,
                       streamPayload: null,
                       cancellationToken: cancellationToken));
        }
示例#2
0
        public void ChangeFeedRequestOptions_MaxItemSizeIsSet()
        {
            RequestMessage           request        = new RequestMessage();
            ChangeFeedRequestOptions requestOptions = new ChangeFeedRequestOptions()
            {
            };

            ChangeFeedRequestOptions.FillMaxItemCount(request, 10);
            requestOptions.PopulateRequestOptions(request);

            Assert.AreEqual("10", request.Headers[Documents.HttpConstants.HttpHeaders.PageSize]);
            Assert.AreEqual(ChangeFeedRequestOptions.IfNoneMatchAllHeaderValue, request.Headers.IfNoneMatch);
            Assert.IsNull(request.Headers[Documents.HttpConstants.HttpHeaders.IfModifiedSince]);
        }
示例#3
0
        /// <summary>
        /// Fill the CosmosRequestMessage headers with the set properties
        /// </summary>
        /// <param name="request">The <see cref="RequestMessage"/></param>
        internal override void PopulateRequestOptions(RequestMessage request)
        {
            // Check if no Continuation Token is present
            if (string.IsNullOrEmpty(request.Headers.IfNoneMatch))
            {
                if (this.StartTime == null)
                {
                    request.Headers.IfNoneMatch = ChangeFeedRequestOptions.IfNoneMatchAllHeaderValue;
                }
                else if (this.StartTime != null &&
                         this.StartTime != ChangeFeedRequestOptions.DateTimeStartFromBeginning)
                {
                    request.Headers.Add(HttpConstants.HttpHeaders.IfModifiedSince, this.StartTime.Value.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture));
                }
            }

            ChangeFeedRequestOptions.FillMaxItemCount(request, this.MaxItemCount);
            request.Headers.Add(HttpConstants.HttpHeaders.A_IM, HttpConstants.A_IMHeaderValues.IncrementalFeed);

            base.PopulateRequestOptions(request);
        }