From 31c2d4b0a2d9350493e56349676d3d3de9d4caa8 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Mon, 8 Jan 2018 10:32:46 -0800 Subject: [PATCH] clientv3: document possible memory pile-up in Watch Signed-off-by: Gyuho Lee --- clientv3/watch.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clientv3/watch.go b/clientv3/watch.go index 24a1b8d6229..312845cbedb 100644 --- a/clientv3/watch.go +++ b/clientv3/watch.go @@ -48,6 +48,8 @@ type Watcher interface { // client will post a compacted error watch response, and the channel will close. // If the context "ctx" is canceled or timed out, returned "WatchChan" is closed, // and "WatchResponse" from this closed channel has zero events and nil "Err()". + // The context "ctx" MUST be canceled, as soon as watcher is no longer being used, + // to release the associated resources. // If the context is "context.Background/TODO", returned "WatchChan" will not be closed // and wait until events happen, except when server returns a non-recoverable error. // For example, when context passed with "WithRequireLeader" and the connected server