From 1fa60c9882b4b47db8b633641ba019acfe64e532 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 19 Oct 2017 14:01:24 -0700 Subject: [PATCH] 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 --- clientv3/watch.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clientv3/watch.go b/clientv3/watch.go index cfa478126..91e6db26a 100644 --- a/clientv3/watch.go +++ b/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 {