private BulkWriteBatchResult ExecuteBatch(RetryableWriteContext context, Batch batch, CancellationToken cancellationToken) { var operation = CreateBatchOperation(batch); var operationResult = RetryableWriteOperationExecutor.Execute(operation, context, cancellationToken); return(CreateBatchResult(batch, operationResult)); }
private async Task <BulkWriteBatchResult> ExecuteBatchAsync(RetryableWriteContext context, Batch batch, CancellationToken cancellationToken) { var operation = CreateBatchOperation(batch); var operationResult = await RetryableWriteOperationExecutor.ExecuteAsync(operation, context, cancellationToken).ConfigureAwait(false); return(CreateBatchResult(batch, operationResult)); }
private async Task <BulkWriteBatchResult> ExecuteBatchAsync(RetryableWriteContext context, Batch batch, CancellationToken cancellationToken) { var operation = CreateBatchOperation(batch); BsonDocument operationResult; try { operationResult = await RetryableWriteOperationExecutor.ExecuteAsync(operation, context, cancellationToken).ConfigureAwait(false); } catch (MongoWriteConcernException exception) when(exception.IsWriteConcernErrorOnly()) { operationResult = exception.Result; } return(CreateBatchResult(batch, operationResult)); }
private BulkWriteBatchResult ExecuteBatch(RetryableWriteContext context, Batch batch, CancellationToken cancellationToken) { var operation = CreateBatchOperation(batch); BsonDocument operationResult; try { operationResult = RetryableWriteOperationExecutor.Execute(operation, context, cancellationToken); } catch (MongoWriteConcernException exception) when(exception.IsWriteConcernErrorOnly()) { operationResult = exception.Result; } return(CreateBatchResult(batch, operationResult)); }
// private methods private void Initialize(CancellationToken cancellationToken) { _channelSource = _binding.GetWriteChannelSource(cancellationToken); var serverDescription = _channelSource.ServerDescription; try { _channel = _channelSource.GetChannel(cancellationToken); } catch (Exception ex) when(RetryableWriteOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription, ex)) { ReplaceChannelSource(_binding.GetWriteChannelSource(cancellationToken)); ReplaceChannel(_channelSource.GetChannel(cancellationToken)); } }
private async Task InitializeAsync(CancellationToken cancellationToken) { _channelSource = await _binding.GetWriteChannelSourceAsync(cancellationToken).ConfigureAwait(false); var serverDescription = _channelSource.ServerDescription; try { _channel = await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false); } catch (Exception ex) when(RetryableWriteOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription, ex)) { ReplaceChannelSource(await _binding.GetWriteChannelSourceAsync(cancellationToken).ConfigureAwait(false)); ReplaceChannel(await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)); } }
// private methods private void Initialize(CancellationToken cancellationToken) { _channelSource = _binding.GetWriteChannelSource(cancellationToken); var serverDescription = _channelSource.ServerDescription; try { _channel = _channelSource.GetChannel(cancellationToken); } catch (MongoConnectionPoolPausedException) { if (RetryableWriteOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription)) { ReplaceChannelSource(_binding.GetWriteChannelSource(cancellationToken)); ReplaceChannel(_channelSource.GetChannel(cancellationToken)); } else { throw; } } }
/// <inheritdoc /> public virtual Task <BsonDocument> ExecuteAsync(RetryableWriteContext context, CancellationToken cancellationToken) { return(RetryableWriteOperationExecutor.ExecuteAsync(this, context, cancellationToken)); }
/// <inheritdoc/> public Task <TResult> ExecuteAsync(RetryableWriteContext context, CancellationToken cancellationToken) { return(RetryableWriteOperationExecutor.ExecuteAsync(this, context, cancellationToken)); }
/// <inheritdoc/> public Task <TResult> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken) { return(RetryableWriteOperationExecutor.ExecuteAsync(this, binding, _retryRequested, cancellationToken)); }