private async Task <IRedisPipeline> ReplaceErrorPipelineAsync(int currentIndex, IRedisPipeline pipeline) { _diagnosticSource.LogEvent("ReplaceErrorPipelineStart", new { CurrentIndex = currentIndex }); var endpoint = await EndpointResolution.GetEndpointAsync(_configuration.Endpoints[0]).ConfigureAwait(false); var newPipeline = await ConnectPipelineAsync(currentIndex, endpoint.Item1, endpoint.Item2).ConfigureAwait(false); _pipelines[currentIndex] = Task.FromResult(newPipeline); try { pipeline.ThrowErrorForRemainingResponseQueueItems(); pipeline.SaveQueue(newPipeline); pipeline.Dispose(); } catch (Exception) { // Ignore } _diagnosticSource.LogEvent("ReplaceErrorPipelineStop", new { CurrentIndex = currentIndex }); return(newPipeline); }
private async Task <Task <IRedisPipeline> > InitializePipelinesAsync() { try { if (_pipelines != null) { return(GetNextPipelineAsync()); } _diagnosticSource.LogEvent("InitializePipelinesAsyncStart"); var endpoint = await EndpointResolution.GetEndpointAsync(_configuration.Endpoints[0]).ConfigureAwait(false); var pipelines = new List <Task <IRedisPipeline> >(); for (var i = 0; i < _capacity; i++) { var pipeline = await ConnectPipelineAsync(i, endpoint.Item1, endpoint.Item2).ConfigureAwait(false); pipelines.Add(Task.FromResult(pipeline)); } _pipelines = pipelines; _diagnosticSource.LogEvent("InitializePipelinesAsyncStop"); return(GetNextPipelineAsync()); } catch (Exception error) { throw new RedisException("Error connecting to server.", error); } finally { _semaphore.Release(); } }