Skip to content

Commit

Permalink
fallback to Node.Address (#21)
Browse files Browse the repository at this point in the history
Service.Address may not always exist, in which case it is safe to fallback to Node.Address
  • Loading branch information
dmarkhas authored Jul 30, 2020
1 parent 8a34ba6 commit cf77658
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ func watchConsulService(ctx context.Context, s servicer, tgt target, out chan<-

ee := make([]string, 0, len(ss))
for _, s := range ss {
ee = append(ee, fmt.Sprintf("%s:%d", s.Service.Address, s.Service.Port))
address := s.Service.Address
if s.Service.Address == "" {
address = s.Node.Address
}
ee = append(ee, fmt.Sprintf("%s:%d", address, s.Service.Port))
}

if tgt.Limit != 0 && len(ee) > tgt.Limit {
ee = ee[:tgt.Limit]
}
Expand Down

0 comments on commit cf77658

Please sign in to comment.