Implement function to wait node for any changes

main
Nikita Tokarchuk 10 months ago
parent e09930bab7
commit aca7879178
Signed by: mainnika
GPG Key ID: A595FB7E3E56911C
  1. 18
      nodesync.go

@ -160,4 +160,20 @@ func (s *NodeSync) WaitEmpty(where string) (err error) {
}
return
}
}
// WaitChanged waits for any changes a zookeeper node and returns a new children list after the change.
// Note: the children list is always stable sorted.
func (s *NodeSync) WaitChanged(where string) (children []string, ev <-chan zk.Event, err error) {
workingPath := path.Join(s.rootPath, where)
children, _, ev, err = s.Zk.ChildrenW(workingPath)
if err != nil {
return
}
children = sortChildren(children)
return
}

Loading…
Cancel
Save