type watcherHub … // newWatchHub creates a watcherHub. The capacity determines how many events we will // keep in the eventHistory. // Typically, we only need to keep a small size of history[smaller than 20K]. // Ideally, it should smaller than 20K/s[max throughput] * 2 * 50ms[RTT] = 2000 func newWatchHub(capacity int) *watcherHub { … } // Watch function returns a Watcher. // If recursive is true, the first change after index under key will be sent to the event channel of the watcher. // If recursive is false, the first change after index at key will be sent to the event channel of the watcher. // If index is zero, watch will start from the current index + 1. func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeIndex uint64) (Watcher, *v2error.Error) { … } func (wh *watcherHub) add(e *Event) { … } // notify function accepts an event and notify to the watchers. func (wh *watcherHub) notify(e *Event) { … } func (wh *watcherHub) notifyWatchers(e *Event, nodePath string, deleted bool) { … } // clone function clones the watcherHub and return the cloned one. // only clone the static content. do not clone the current watchers. func (wh *watcherHub) clone() *watcherHub { … } // isHidden checks to see if key path is considered hidden to watch path i.e. the // last element is hidden or it's within a hidden directory func isHidden(watchPath, keyPath string) bool { … }