type FilterFunc … // Filter passes all events through f before allowing them to pass on. // Putting a filter on a watch, as an unavoidable side-effect due to the way // go channels work, effectively causes the watch's event channel to have its // queue length increased by one. // // WARNING: filter has a fatal flaw, in that it can't properly update the // Type field (Add/Modified/Deleted) to reflect items beginning to pass the // filter when they previously didn't. func Filter(w Interface, f FilterFunc) Interface { … } type filteredWatch … // ResultChan returns a channel which will receive filtered events. func (fw *filteredWatch) ResultChan() <-chan Event { … } // Stop stops the upstream watch, which will eventually stop this watch. func (fw *filteredWatch) Stop() { … } // loop waits for new values, filters them, and resends them. func (fw *filteredWatch) loop() { … } type Recorder … var _ … // NewRecorder wraps an Interface and records any changes sent across it. func NewRecorder(w Interface) *Recorder { … } // record is a FilterFunc and tracks each received event. func (r *Recorder) record(in Event) (Event, bool) { … } // Events returns a copy of the events sent across this recorder. func (r *Recorder) Events() []Event { … }