Implement function to wait node to be empty

main
Nikita Tokarchuk 2 years ago
parent 8977dfc920
commit e09930bab7
Signed by: mainnika
GPG Key ID: A595FB7E3E56911C
  1. 24
      nodesync.go

@ -137,3 +137,27 @@ func (s *NodeSync) Unlock(where string, iam string) (err error) {
return
}
// WaitEmpty implements a barrier synchronisation mechanism by waiting for empty node.
func (s *NodeSync) WaitEmpty(where string) (err error) {
workingPath := path.Join(s.rootPath, where)
for {
var children []string
var ev <-chan zk.Event
children, _, ev, err = s.Zk.ChildrenW(workingPath)
if err != nil {
return
}
if len(children) == 0 {
break
}
<-ev
}
return
}
Loading…
Cancel
Save