clientv3/watch.go
func (w *watchGrpcStream) openWatchClient() (ws pb.Watch_WatchClient, err error) {
	backoff := time.Millisecond
	for {
		select {
		case <-w.ctx.Done():
			if err == nil {
				return nil, w.ctx.Err()
			}
			return nil, err
		default:
		}
		if ws, err = w.remote.Watch(w.ctx, w.callOpts...); ws != nil && err == nil {
			break
		}
		if isHaltErr(w.ctx, err) {
			return nil, v3rpc.Error(err)
		}
		if isUnavailableErr(w.ctx, err) {
			// retry, but backoff
			if backoff < maxBackoff {
				// 25% backoff factor
				backoff = backoff + backoff/4
				if backoff > maxBackoff {
					backoff = maxBackoff
				}
			}
			time.Sleep(backoff)
		}
	}
	return ws, nil
}
func (w *watchGrpcStream) openWatchClient() (ws pb.Watch_WatchClient, err error) {
	backoff := time.Millisecond
	for {
		select {
		case <-w.ctx.Done():
			if err == nil {
				return nil, w.ctx.Err()
			}
			return nil, err
		default:
		}
		if ws, err = w.remote.Watch(w.ctx, w.callOpts...); ws != nil && err == nil {
			break
		}
		if isHaltErr(w.ctx, err) {
			return nil, v3rpc.Error(err)
		}
		if isUnavailableErr(w.ctx, err) {
			// retry, but backoff
			if backoff < maxBackoff {
				// 25% backoff factor
				backoff = backoff + backoff/4
				if backoff > maxBackoff {
					backoff = maxBackoff
				}
			}
			time.Sleep(backoff)
		}
	}
	return ws, nil
}
func ( w * watchGrpcStream ) openWatchClient ( ) ( ws pb . Watch_WatchClient , err error ) { backoff := time . Millisecond for { select { case <- w . ctx . Done ( ) : if err == nil { return nil , w . ctx . Err ( ) } return nil , err default : } if ws , err = w . remote . Watch ( w . ctx , w . callOpts ... ) ; ws != nil && err == nil { break } if isHaltErr ( w . ctx , err ) { return nil , v3rpc . Error ( err ) } if isUnavailableErr ( w . ctx , err ) { // retry, but backoff if backoff < maxBackoff { // 25% backoff factor backoff = backoff + backoff / 4 if backoff > maxBackoff { backoff = maxBackoff } } time . Sleep ( backoff ) } } return ws , nil }
// openWatchClient retries opening a watch client until success or halt.
// manually retry in case "ws==nil && err==nil"
// TODO: remove FailFast=false
openWatchClient retries opening a watch client until success or halt . manually retry in case ws == nil && err == nil TODO : remove FailFast = false