mirror of https://github.com/docker/docs.git
Fix zookeeper watch that was triggered only once
Signed-off-by: Alexandre Beslic <abronan@docker.com>
This commit is contained in:
parent
0b24992d7c
commit
dedb0ed906
|
@ -157,7 +157,7 @@ func (s *Zookeeper) Watch(key string, stopCh <-chan struct{}) (<-chan *KVPair, e
|
|||
// Providing a non-nil stopCh can be used to stop watching.
|
||||
func (s *Zookeeper) WatchTree(prefix string, stopCh <-chan struct{}) (<-chan []*KVPair, error) {
|
||||
fprefix := normalize(prefix)
|
||||
entries, stat, eventCh, err := s.client.ChildrenW(fprefix)
|
||||
entries, err := s.List(prefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -168,13 +168,13 @@ func (s *Zookeeper) WatchTree(prefix string, stopCh <-chan struct{}) (<-chan []*
|
|||
defer close(watchCh)
|
||||
|
||||
// GetW returns the current value before setting the watch.
|
||||
kv := []*KVPair{}
|
||||
for _, item := range entries {
|
||||
kv = append(kv, &KVPair{prefix, []byte(item), uint64(stat.Mzxid)})
|
||||
}
|
||||
watchCh <- kv
|
||||
watchCh <- entries
|
||||
|
||||
for {
|
||||
_, _, eventCh, err := s.client.ChildrenW(fprefix)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
select {
|
||||
case e := <-eventCh:
|
||||
if e.Type == zk.EventNodeChildrenChanged {
|
||||
|
|
Loading…
Reference in New Issue