示例#1
0
        // 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));
            }
        }
示例#2
0
        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));
            }
        }
示例#3
0
        // 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;
                }
            }
        }