コード例 #1
0
        /// <summary>
        /// Based on the Retry Policy, if a failed response should retry.
        /// </summary>
        public Task <ShouldRetryResult> ShouldRetryAsync(
            BatchOperationResult batchOperationResult,
            CancellationToken cancellationToken)
        {
            if (this.retryPolicy == null ||
                batchOperationResult.IsSuccessStatusCode)
            {
                return(Task.FromResult(ShouldRetryResult.NoRetry()));
            }

            ResponseMessage responseMessage = batchOperationResult.ToResponseMessage();

            return(this.retryPolicy.ShouldRetryAsync(responseMessage, cancellationToken));
        }
コード例 #2
0
        private async Task <ResponseMessage> ProcessResourceOperationAsBulkStreamAsync(
            Uri resourceUri,
            ResourceType resourceType,
            OperationType operationType,
            RequestOptions requestOptions,
            ContainerCore cosmosContainerCore,
            PartitionKey partitionKey,
            string itemId,
            Stream streamPayload,
            Action <RequestMessage> requestEnricher,
            CancellationToken cancellationToken)
        {
            ItemRequestOptions      itemRequestOptions      = requestOptions as ItemRequestOptions;
            BatchItemRequestOptions batchItemRequestOptions = BatchItemRequestOptions.FromItemRequestOptions(itemRequestOptions);
            ItemBatchOperation      itemBatchOperation      = new ItemBatchOperation(operationType, /* index */ 0, partitionKey, itemId, streamPayload, batchItemRequestOptions);
            BatchOperationResult    batchOperationResult    = await cosmosContainerCore.BatchExecutor.AddAsync(itemBatchOperation, itemRequestOptions, cancellationToken);

            return(batchOperationResult.ToResponseMessage());
        }