private BulkWriteOperationResult CreateAndRunBulkOperation(RetryableWriteContext context, bool async) { var bulkInsertOperation = new BulkInsertOperation( _collectionNamespace, new[] { new InsertRequest(new BsonDocument()) }, _messageEncoderSettings); if (async) { return(bulkInsertOperation.ExecuteAsync(context, CancellationToken.None).GetAwaiter().GetResult()); } else { return(bulkInsertOperation.Execute(context, CancellationToken.None)); } }
public static bool DoesContextAllowRetries(RetryableWriteContext context) => (bool)Reflector.InvokeStatic(typeof(RetryableWriteOperationExecutor), nameof(DoesContextAllowRetries), context);
private RetryableWriteContext CreateContext(bool retryRequested, bool areRetryableWritesSupported, bool hasSessionId, bool isInTransaction) { var binding = CreateBinding(areRetryableWritesSupported, hasSessionId, isInTransaction); return(RetryableWriteContext.Create(binding, retryRequested, CancellationToken.None)); }
private RetryableWriteContext CreateRetryableWriteContext(IReadWriteBindingHandle readWriteBindingHandle, bool async) { return(async ? RetryableWriteContext.CreateAsync(readWriteBindingHandle, retryRequested: false, CancellationToken.None).GetAwaiter().GetResult() : RetryableWriteContext.Create(readWriteBindingHandle, retryRequested: false, CancellationToken.None)); }