Beispiel #1
0
        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);
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 public bool InSameRegionAs(RedisHost host) => string.Equals(Region, host.Region, StringComparison.OrdinalIgnoreCase);
Beispiel #4
0
 internal RedisConnectionInfo(RedisHost server, RedisSettings.Instance settings, AddressCache addressCache)
 {
     Server       = server;
     Settings     = settings;
     AddressCache = addressCache;
 }