private List <RedisConnectionInfo> LoadRedisConnections(RedisSettings settings, AddressCache addressCache) { var result = new List <RedisConnectionInfo>(); var defaultServerInstances = settings.Defaults.Instances; var allServerInstances = settings.AllServers.Instances ?? Enumerable.Empty <RedisSettings.Instance>(); foreach (var s in settings.Servers) { var server = new RedisHost(this, s); var count = result.Count; // Add instances that belong to any servers foreach (var asi in allServerInstances) { result.Add(new RedisConnectionInfo(server, asi, addressCache)); } // Add instances defined on this server foreach (var si in s.Instances) { result.Add(new RedisConnectionInfo(server, si, addressCache)); } // If we have no instances added at this point, defaults it is! if (defaultServerInstances != null && count == result.Count) { foreach (var dsi in defaultServerInstances) { result.Add(new RedisConnectionInfo(server, dsi, addressCache)); } } } return(result); }
public bool CanReplicateFrom(RedisHost host, out string reason) { foreach (var i in Instances) { foreach (var di in i.GetAllReplicasInChain()) { if (di?.ConnectionInfo?.Server == host) { reason = $"Current chain contains {di.HostAndPort}"; return(false); } } } reason = ""; return(true); }
public bool InSameRegionAs(RedisHost host) => string.Equals(Region, host.Region, StringComparison.OrdinalIgnoreCase);
internal RedisConnectionInfo(RedisHost server, RedisSettings.Instance settings, AddressCache addressCache) { Server = server; Settings = settings; AddressCache = addressCache; }