private RedisSentinelWorker GetNextSentinel() { RedisSentinelWorker disposeWorker = null; try { lock (oLock) { if (this.worker != null) { disposeWorker = this.worker; this.worker = null; } if (++sentinelIndex >= SentinelEndpoints.Length) { sentinelIndex = 0; } var sentinelWorker = new RedisSentinelWorker(this, SentinelEndpoints[sentinelIndex]) { OnSentinelError = OnSentinelError }; return(sentinelWorker); } } finally { disposeWorker?.Dispose(); } }
public void Dispose() { if (worker != null) { worker.Dispose(); worker = null; } }
public void Dispose() { if (worker != null) { worker.SentinelError -= Worker_SentinelError; worker.Dispose(); worker = null; } }
private void GetValidSentinel() { while (this.clientManager == null && failures < RedisSentinel.MaxFailures) { try { worker = GetNextSentinel(); clientManager = worker.GetClientManager(); worker.BeginListeningForConfigurationChanges(); } catch (RedisException) { if (worker != null) { worker.SentinelError -= Worker_SentinelError; worker.Dispose(); } failures++; } } }
private RedisSentinelWorker GetNextSentinel() { RedisSentinelWorker disposeWorker = null; try { lock (oLock) { if (this.worker != null) { disposeWorker = this.worker; this.worker = null; } if (++sentinelIndex >= SentinelEndpoints.Length) { sentinelIndex = 0; } if (Log.IsDebugEnabled) { Log.Debug($"Attempt to connect to next sentinel '{SentinelEndpoints[sentinelIndex]}'..."); } var sentinelWorker = new RedisSentinelWorker(this, SentinelEndpoints[sentinelIndex]) { OnSentinelError = OnSentinelError }; return(sentinelWorker); } } finally { disposeWorker?.Dispose(); } }