Skip to content

Commit cf77658

Browse files
authored
fallback to Node.Address (#21)
Service.Address may not always exist, in which case it is safe to fallback to Node.Address
1 parent 8a34ba6 commit cf77658

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

consul.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ func watchConsulService(ctx context.Context, s servicer, tgt target, out chan<-
7676

7777
ee := make([]string, 0, len(ss))
7878
for _, s := range ss {
79-
ee = append(ee, fmt.Sprintf("%s:%d", s.Service.Address, s.Service.Port))
79+
address := s.Service.Address
80+
if s.Service.Address == "" {
81+
address = s.Node.Address
82+
}
83+
ee = append(ee, fmt.Sprintf("%s:%d", address, s.Service.Port))
8084
}
85+
8186
if tgt.Limit != 0 && len(ee) > tgt.Limit {
8287
ee = ee[:tgt.Limit]
8388
}

0 commit comments

Comments
 (0)