Lookup every service. FML

This commit is contained in:
Asim Aslam 2019-06-27 14:37:52 +01:00
parent 9630e153a5
commit 67e3d560fe

View File

@ -107,7 +107,20 @@ func (r *router) addServiceRoutes(reg registry.Registry, network string, metric
// add each service node as a separate route; // add each service node as a separate route;
for _, service := range services { for _, service := range services {
for _, node := range service.Nodes { // get the service to retrieve all its info
srvs, err := reg.GetService(service.Name)
if err != nil {
continue
}
// create a flat slide of nodes
var nodes []*registry.Node
for _, s := range srvs {
nodes = append(nodes, s.Nodes...)
}
// range over the flat slice of nodes
for _, node := range nodes {
gw := node.Address gw := node.Address
if node.Port > 0 { if node.Port > 0 {
gw = fmt.Sprintf("%s:%d", node.Address, node.Port) gw = fmt.Sprintf("%s:%d", node.Address, node.Port)