|
|
|
@ -44,10 +44,14 @@ func (s *ZkClient) watch() {
|
|
|
|
|
|
|
|
|
|
func (s *ZkClient) GetConnsRemote(serviceName string) (conns []resolver.Address, err error) {
|
|
|
|
|
path := s.getPath(serviceName)
|
|
|
|
|
_, _, _, err = s.conn.ChildrenW(path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, errors.Wrap(err, "children watch error")
|
|
|
|
|
}
|
|
|
|
|
childNodes, _, err := s.conn.Children(path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, errors.Wrap(err, "get children error")
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for _, child := range childNodes {
|
|
|
|
|
fullPath := path + "/" + child
|
|
|
|
|
data, _, err := s.conn.Get(fullPath)
|
|
|
|
@ -60,9 +64,6 @@ func (s *ZkClient) GetConnsRemote(serviceName string) (conns []resolver.Address,
|
|
|
|
|
log.ZDebug(context.Background(), "get conns from remote", "conn", string(data))
|
|
|
|
|
conns = append(conns, resolver.Address{Addr: string(data), ServerName: serviceName})
|
|
|
|
|
}
|
|
|
|
|
_, _, _, err = s.conn.ChildrenW(path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, errors.Wrap(err, "children watch error")
|
|
|
|
|
}
|
|
|
|
|
return conns, nil
|
|
|
|
|
}
|
|
|
|
|