From 44935c2f946e4683bf920a05f8e9eec9de1ca991 Mon Sep 17 00:00:00 2001 From: Nan Deng Date: Tue, 1 Jul 2014 11:21:17 -0700 Subject: [PATCH] comment --- pkg/util/fake_etcd_client.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/util/fake_etcd_client.go b/pkg/util/fake_etcd_client.go index df6ac54c767..635d6236191 100644 --- a/pkg/util/fake_etcd_client.go +++ b/pkg/util/fake_etcd_client.go @@ -52,7 +52,18 @@ func MakeFakeEtcdClient(t *testing.T) *FakeEtcdClient { t: t, Data: map[string]EtcdResponseWithError{}, } - // Watch() method has not been called. + // There are three publicly accessible channels in FakeEtcdClient: + // - WatchResponse + // - WatchInjectError + // - WatchStop + // They are only available when Watch() is called. If users of + // FakeEtcdClient want to use any of these channels, they have to call + // WaitForWatchCompletion before any operation on these channels. + // Internally, FakeEtcdClient use condWatchCompleted to indicate if the + // Watch() method has been called. WaitForWatchCompletion() will wait + // on condWatchCompleted. By the end of the Watch() method, it will + // call Broadcast() on condWatchCompleted, which will awake any + // goroutine waiting on this condition. ret.condWatchCompleted = sync.NewCond(&ret.condLock) return ret }