public void RefreshActiveSentinels() { var activeHosts = GetActiveSentinelHosts(SentinelHosts); if (activeHosts.Count == 0) { return; } lock (SentinelHosts) { lastSentinelsRefresh = DateTime.UtcNow; activeHosts.Each(x => { if (!SentinelHosts.Contains(x)) { SentinelHosts.Add(x); } }); SentinelEndpoints = SentinelHosts .Map(x => x.ToRedisEndpoint(defaultPort: RedisConfig.DefaultPortSentinel)) .ToArray(); } }
/// <summary> /// Initialize Sentinel Subscription and Configure Redis ClientsManager /// </summary> public IRedisClientsManager Start() { lock (oLock) { for (int i = 0; i < SentinelHosts.Count; i++) { var parts = SentinelHosts[i].SplitOnLast(':'); if (parts.Length == 1) { SentinelHosts[i] = parts[0] + ":" + RedisConfig.DefaultPortSentinel; } } if (ScanForOtherSentinels) { RefreshActiveSentinels(); } SentinelEndpoints = SentinelHosts .Map(x => x.ToRedisEndpoint(defaultPort: RedisConfig.DefaultPortSentinel)) .ToArray(); var sentinelWorker = GetValidSentinelWorker(); if (this.RedisManager == null || sentinelWorker == null) { throw new Exception("Unable to resolve sentinels!"); } return(this.RedisManager); } }