/// <inheritdoc />
 public virtual async Task <BsonDocument> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (var context = await RetryableWriteContext.CreateAsync(binding, _retryRequested, cancellationToken).ConfigureAwait(false))
     {
         return(Execute(context, cancellationToken));
     }
 }
 public async static Task <TResult> ExecuteAsync <TResult>(IRetryableWriteOperation <TResult> operation, IWriteBinding binding, bool retryRequested, CancellationToken cancellationToken)
 {
     using (var context = await RetryableWriteContext.CreateAsync(binding, retryRequested, cancellationToken).ConfigureAwait(false))
     {
         return(await ExecuteAsync(operation, context, cancellationToken).ConfigureAwait(false));
     }
 }
        /// <inheritdoc/>
        public async Task <WriteConcernResult> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, nameof(binding));

            using (var context = await RetryableWriteContext.CreateAsync(binding, false, cancellationToken).ConfigureAwait(false))
            {
                return(await ExecuteAsync(context, cancellationToken).ConfigureAwait(false));
            }
        }
 public async Task <BulkWriteOperationResult> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var context = await RetryableWriteContext.CreateAsync(binding, _retryRequested, cancellationToken).ConfigureAwait(false))
         {
             context.DisableRetriesIfAnyWriteRequestIsNotRetryable(_requests);
             return(await ExecuteAsync(context, cancellationToken).ConfigureAwait(false));
         }
 }
示例#5
0
        /// <inheritdoc/>
        public async Task <IEnumerable <WriteConcernResult> > ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, nameof(binding));

            using (EventContext.BeginOperation())
                using (var context = await RetryableWriteContext.CreateAsync(binding, false, cancellationToken).ConfigureAwait(false))
                {
                    var emulator = CreateEmulator();
                    var result   = await emulator.ExecuteAsync(context, cancellationToken).ConfigureAwait(false);

                    return(result != null ? new[] { result } : null);
                }
        }
示例#6
0
 /// <inheritdoc/>
 public async Task <BulkWriteOperationResult> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var context = await RetryableWriteContext.CreateAsync(binding, _retryRequested, cancellationToken).ConfigureAwait(false))
         {
             context.DisableRetriesIfAnyWriteRequestIsNotRetryable(_requests);
             var helper = new BatchHelper(_requests, _isOrdered, _writeConcern);
             foreach (var batch in helper.GetBatches())
             {
                 batch.Result = await ExecuteBatchAsync(context, batch, cancellationToken).ConfigureAwait(false);
             }
             return(helper.GetFinalResultOrThrow(context.Channel.ConnectionDescription.ConnectionId));
         }
 }
示例#7
0
        /// <inheritdoc/>
        public async Task <IEnumerable <WriteConcernResult> > ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, nameof(binding));

            using (EventContext.BeginOperation())
                using (var context = await RetryableWriteContext.CreateAsync(binding, false, cancellationToken).ConfigureAwait(false))
                {
                    if (_writeConcern.IsAcknowledged)
                    {
                        var emulator = CreateEmulator();
                        var result   = await emulator.ExecuteAsync(context, cancellationToken).ConfigureAwait(false);

                        return(new[] { result });
                    }
                    else
                    {
                        return(await InsertBatchesAsync(context.Channel, cancellationToken).ConfigureAwait(false));
                    }
                }
        }