Exemple #1
0
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            _channelSource = await _binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                _channel = await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (Exception ex) when(RetryableReadOperationExecutor.ShouldConnectionAcquireBeRetried(this, ex))
            {
                ReplaceChannelSource(await _binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false));
                ReplaceChannel(await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false));
            }
        }
Exemple #2
0
        private void Initialize(CancellationToken cancellationToken)
        {
            _channelSource = _binding.GetReadChannelSource(cancellationToken);

            try
            {
                _channel = _channelSource.GetChannel(cancellationToken);
            }
            catch (Exception ex) when(RetryableReadOperationExecutor.ShouldConnectionAcquireBeRetried(this, ex))
            {
                ReplaceChannelSource(_binding.GetReadChannelSource(cancellationToken));
                ReplaceChannel(_channelSource.GetChannel(cancellationToken));
            }
        }
        private void Initialize(CancellationToken cancellationToken)
        {
            _channelSource = _binding.GetReadChannelSource(cancellationToken);
            var serverDescription = _channelSource.ServerDescription;

            try
            {
                _channel = _channelSource.GetChannel(cancellationToken);
            }
            catch (MongoConnectionPoolPausedException)
            {
                if (RetryableReadOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription))
                {
                    ReplaceChannelSource(_binding.GetReadChannelSource(cancellationToken));
                    ReplaceChannel(_channelSource.GetChannel(cancellationToken));
                }
                else
                {
                    throw;
                }
            }
        }
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            _channelSource = await _binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false);

            var serverDescription = _channelSource.ServerDescription;

            try
            {
                _channel = await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (MongoConnectionPoolPausedException)
            {
                if (RetryableReadOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription))
                {
                    ReplaceChannelSource(await _binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false));
                    ReplaceChannel(await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false));
                }
                else
                {
                    throw;
                }
            }
        }