go-zookeeper icon indicating copy to clipboard operation
go-zookeeper copied to clipboard

Add watcher type and the ability to remove watcher

Open tevino opened this issue 8 years ago • 4 comments

camlistore.org/pkg/throttle is broken, switched to go4.org/net/throttle


  1. GetW ExistsW and ChildrenW return a *Watcher at the position of <-chan Event
  2. The watcher could be removed(thus stopped) by Conn.RemoveWatcher(watcher)
  3. The chan within a manually removed watcher will receive a special Event with ErrWatcherRemoved
  4. WatchType and WatchPathType are exported

tevino avatar Apr 11 '16 08:04 tevino

Does this have any chance to be merged ? Is there something we can do to help get it merged ?

cerisier avatar May 05 '16 20:05 cerisier

I'm not sure if @samuel is still maintaining this repo. You can just use the fork (as I did) for now. @cerisier

tevino avatar May 06 '16 02:05 tevino

Does this have any chance to be merged ? Is there something we can do to help get it merged ?

I used this library in my project, which caused a memory leak. The pprof file shows that addwatcher () takes up too much memory, so I want to use removeaddwatcher (). Have you actually used the PR code? My project is https://github.com/apache/dubbo-go,Looking forward to communicating with you

pantianying avatar Jan 31 '20 07:01 pantianying

I found the same problem from my source code

//conn.go line 950
c.watchersLock.Lock() 
defer c.watchersLock.Unlock() 
ch := make(chan Event, 1)    //canot remove. caused memory leak
wpt := watchPathType{path, watchType} 
c.watchers[wpt] = append(c.watchers[wpt], ch) 

@samuel

wanyvic avatar Mar 04 '20 08:03 wanyvic