Encapsulate WaitGroup with the goroutines being synchronized
@@ -70,6 +70,8 @@ func (w *ClusterWatch) Start() (StopFunc, error) {
events, shutdownCh := consumeEvents(done, watchers)
allDone := make(chan interface{})
+
+ go func() {
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
@@ -87,7 +89,6 @@ func (w *ClusterWatch) Start() (StopFunc, error) {
wg.Done()
}()
- go func() {
// Block until fan-in consumer as well as individual watch consumers have completed
// (above two goroutines)
wg.Wait()
