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

            using (var context = RetryableWriteContext.Create(binding, false, cancellationToken))
            {
                return(Execute(context, cancellationToken));
            }
        }
 public BulkWriteOperationResult Execute(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var context = RetryableWriteContext.Create(binding, _retryRequested, cancellationToken))
         {
             context.DisableRetriesIfAnyWriteRequestIsNotRetryable(_requests);
             return(Execute(context, cancellationToken));
         }
 }
Exemple #5
0
        // public methods
        /// <inheritdoc/>
        public IEnumerable <WriteConcernResult> Execute(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, nameof(binding));

            using (EventContext.BeginOperation())
                using (var context = RetryableWriteContext.Create(binding, false, cancellationToken))
                {
                    var emulator = CreateEmulator();
                    var result   = emulator.Execute(context, cancellationToken);
                    return(result != null ? new[] { result } : null);
                }
        }
Exemple #6
0
 // public methods
 /// <inheritdoc/>
 public BulkWriteOperationResult Execute(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var context = RetryableWriteContext.Create(binding, _retryRequested, cancellationToken))
         {
             context.DisableRetriesIfAnyWriteRequestIsNotRetryable(_requests);
             var helper = new BatchHelper(_requests, _isOrdered, _writeConcern);
             foreach (var batch in helper.GetBatches())
             {
                 batch.Result = ExecuteBatch(context, batch, cancellationToken);
             }
             return(helper.GetFinalResultOrThrow(context.Channel.ConnectionDescription.ConnectionId));
         }
 }
Exemple #7
0
        // public methods
        /// <inheritdoc/>
        public IEnumerable <WriteConcernResult> Execute(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, nameof(binding));

            using (EventContext.BeginOperation())
                using (var context = RetryableWriteContext.Create(binding, false, cancellationToken))
                {
                    if (_writeConcern.IsAcknowledged)
                    {
                        var emulator = CreateEmulator();
                        var result   = emulator.Execute(context, cancellationToken);
                        return(new[] { result });
                    }
                    else
                    {
                        return(InsertBatches(context.Channel, cancellationToken));
                    }
                }
        }