fix wait_index
parent
1caf2a3364
commit
2022c4bce6
|
@ -15,6 +15,7 @@ type watcherHub struct {
|
|||
type watcher struct {
|
||||
eventChan chan *Event
|
||||
recursive bool
|
||||
sinceIndex uint64
|
||||
}
|
||||
|
||||
func newWatchHub(capacity int) *watcherHub {
|
||||
|
@ -45,6 +46,7 @@ func (wh *watcherHub) watch(prefix string, recursive bool, index uint64) (<-chan
|
|||
w := &watcher{
|
||||
eventChan: eventChan,
|
||||
recursive: recursive,
|
||||
sinceIndex: index,
|
||||
}
|
||||
|
||||
l, ok := wh.watchers[prefix]
|
||||
|
@ -85,7 +87,7 @@ func (wh *watcherHub) notifyWithPath(e *Event, path string, force bool) {
|
|||
|
||||
w, _ := curr.Value.(*watcher)
|
||||
|
||||
if w.recursive || force || e.Key == path {
|
||||
if (w.recursive || force || e.Key == path) && e.Index >= w.sinceIndex {
|
||||
w.eventChan <- e
|
||||
l.Remove(curr)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue