func getHosts() []string { hostsConfigPath := []string{"hailo", "service", "zookeeper", "hosts"} tier := config.AtPath("hailo", "service", "zookeeper", "tier").AsString("general") if tier != "general" { hostsConfigPath = append(hostsConfigPath, tier) } if hosts := config.AtPath(hostsConfigPath...).AsHostnameArray(2181); len(hosts) > 0 { return hosts } // no hosts returned so try dns hosts, err := dns.Hosts("zookeeper-" + tier) if err != nil { log.Errorf("Failed to load ZK hosts from dns: %v", err) return []string{"localhost:2181"} } // for safety fall back to localhost if len(hosts) == 0 { return []string{"localhost:2181"} } // append port for i, host := range hosts { hosts[i] = host + ":2181" } return hosts }
func getHosts() []string { hostConfigPath := []string{"hailo", "service", "memcache", "servers"} host := "memcached" // check if tier is specified and act accordingly tier := config.AtPath("hailo", "service", "memcache", "tier").AsString("") if tier != "" { hostConfigPath = append(hostConfigPath, tier) host = fmt.Sprintf("%s-%s", host, tier) } if hosts := config.AtPath(hostConfigPath...).AsHostnameArray(11211); len(hosts) > 0 { return hosts } // no hosts returned so try dns hosts, err := dns.Hosts(host) if err != nil { log.Errorf("[Memcache] Failed to load hosts from dns, returning empty list: %v", err) return []string{} } // append port for i, host := range hosts { hosts[i] = host + ":11211" } return hosts }
func getHosts(port int, path ...string) []string { if hosts := config.AtPath(path...).AsHostnameArray(port); len(hosts) > 0 { return hosts } // should we lookup dns? if config.AtPath("hailo", "service", "nsq", "disableDnsLookup").AsBool() { return []string{} } // try dns lookup cluster := config.AtPath("hailo", "service", "nsq", "cluster").AsString("general") hosts, err := dns.Hosts("nsq-" + cluster) if err != nil { log.Errorf("Failed to load NSQ hosts from dns: %v", err) return []string{} } // append port for i, host := range hosts { hosts[i] = fmt.Sprintf("%s:%d", host, port) } return hosts }
func getHosts() []string { port := config.AtPath("hailo", "service", "cassandra", "defaults", "cqlPort").AsInt(defaultPort) hosts := config.AtPath("hailo", "service", "cassandra", hostsCfgKey()).AsHostnameArray(port) if len(hosts) > 0 { return hosts } // No hosts returned: try DNS tier := config.AtPath("hailo", "service", "cassandra", "tier").AsString("premium") hosts, err := dns.Hosts("cassandra-" + tier) if err != nil { log.Errorf("[Cassandra] Failed to load hosts from DNS: %s", err.Error()) return defaultHosts } if len(hosts) == 0 { return defaultHosts } // We need to append the port to hosts coming from DNS for i, host := range hosts { hosts[i] = host + fmt.Sprintf(":%d", port) } return hosts }
func getHosts() []string { cassandraHostKey := getCassandraHostConfigKey() config.WaitUntilLoaded(5 * time.Second) port := config.AtPath("hailo", "service", "cassandra", "defaults", "thriftPort").AsInt(defaultPort) if hosts := config.AtPath("hailo", "service", "cassandra", cassandraHostKey).AsHostnameArray(port); len(hosts) > 0 { return hosts } // No hosts returned: try DNS tier := config.AtPath("hailo", "service", "cassandra", "tier").AsString("premium") hosts, err := dns.Hosts("cassandra-" + tier) if err != nil { log.Errorf("Failed to load Cassandra hosts from dns: %v", err) return defaultHosts } if len(hosts) == 0 { return defaultHosts } // We need to append the port to hosts coming from DNS for i, host := range hosts { hosts[i] = host + fmt.Sprintf(":%d", port) } return hosts }