Browse Source

clientv3: add TODO for watch retry

Later we can do:

```diff
+// RetryWatchClient implements a WatchClient.
+func RetryWatchClient(c *Client) pb.WatchClient {
+	readRetry := c.newRetryWrapper(isReadStopError)
+	wc := pb.NewWatchClient(c.conn)
+	return &retryWatchClient{wc, readRetry}
+}
+
+type retryWatchClient struct {
+	pb.WatchClient
+	readRetry retryRPCFunc
+}
+
+func (rwc *retryWatchClient) Watch(ctx context.Context, opts ...grpc.CallOption) (stream pb.Watch_WatchClient, err error) {
+	err = rwc.readRetry(ctx, func(rctx context.Context) error {
+		stream, err = rwc.WatchClient.Watch(rctx, opts...)
+		return err
+	})
+	return stream, err
+}

-	return NewWatchFromWatchClient(pb.NewWatchClient(c.conn))
+	return NewWatchFromWatchClient(RetryWatchClient(c))
```

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
Gyu-Ho Lee 8 years ago
parent
commit
1fa60c9882
1 changed files with 2 additions and 0 deletions
  1. 2 0
      clientv3/watch.go

+ 2 - 0
clientv3/watch.go

@@ -762,6 +762,8 @@ func (w *watchGrpcStream) joinSubstreams() {
 }
 
 // openWatchClient retries opening a watch client until success or halt.
+// manually retry in case "ws==nil && err==nil"
+// TODO: remove FailFast=false
 func (w *watchGrpcStream) openWatchClient() (ws pb.Watch_WatchClient, err error) {
 	for {
 		select {