Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Nov 27, 2024
1 parent 861c9fc commit fc51ff6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 3 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ func (c *client) GetRegion(ctx context.Context, key []byte, opts ...opt.GetRegio
RegionKey: key,
NeedBuckets: options.NeedBuckets,
}
serviceClient, cctx := c.inner.getRegionAPIClientAndContext(ctx, options.AllowFollowerHandle && c.inner.option.GetEnableFollowerHandle())
serviceClient, cctx := c.inner.getRegionAPIClientAndContext(ctx,
options.AllowFollowerHandle && c.inner.option.GetEnableFollowerHandle())
if serviceClient == nil {
return nil, errs.ErrClientGetProtoClient
}
Expand All @@ -729,7 +730,7 @@ func (c *client) GetRegion(ctx context.Context, key []byte, opts ...opt.GetRegio
}
resp, err = protoClient.GetRegion(cctx, req)
}
if err = c.respForErr(metrics.CmdDurationGetRegion, start, err, resp.GetHeader()); err != nil {
if err = c.respForErr(metrics.CmdFailedDurationGetRegion, start, err, resp.GetHeader()); err != nil {
return nil, err
}
return handleRegionResponse(resp), nil
Expand Down
1 change: 0 additions & 1 deletion client/errs/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ var (
// client errors
var (
ErrClientGetProtoClient = errors.Normalize("failed to get proto client", errors.RFCCodeText("PD:client:ErrClientGetProtoClient"))
ErrClientInvalidResponseType = errors.Normalize("invalid response type", errors.RFCCodeText("PD:client:ErrClientInvalidResponseType"))
ErrClientGetMetaStorageClient = errors.Normalize("failed to get meta storage client", errors.RFCCodeText("PD:client:ErrClientGetMetaStorageClient"))
ErrClientCreateTSOStream = errors.Normalize("create TSO stream failed, %s", errors.RFCCodeText("PD:client:ErrClientCreateTSOStream"))
ErrClientTSOStreamClosed = errors.Normalize("encountered TSO stream being closed unexpectedly", errors.RFCCodeText("PD:client:ErrClientTSOStreamClosed"))
Expand Down
10 changes: 4 additions & 6 deletions client/pkg/utils/grpcutil/grpcutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func GetClientConn(ctx context.Context, addr string, tlsCfg *tls.Config, do ...g
creds := credentials.NewTLS(tlsCfg)
opt = grpc.WithTransportCredentials(creds)
}
u, err := url.Parse(addr)
if err != nil {
return nil, errs.ErrURLParse.Wrap(err).GenWithStackByCause()
}

// Add retry interceptor
retryOpt := grpc.WithUnaryInterceptor(UnaryBackofferInterceptor())
Expand All @@ -123,12 +127,6 @@ func GetClientConn(ctx context.Context, addr string, tlsCfg *tls.Config, do ...g
})

do = append(do, opt, retryOpt, backoffOpts)

u, err := url.Parse(addr)
if err != nil {
return nil, errs.ErrURLParse.Wrap(err).GenWithStackByCause()
}

cc, err := grpc.DialContext(ctx, u.Host, do...)
if err != nil {
return nil, errs.ErrGRPCDial.Wrap(err).GenWithStackByCause()
Expand Down

0 comments on commit fc51ff6

Please sign in to comment.