Skip to content

Commit

Permalink
clientv3: get AuthToken automatically when clientConn is ready. (#12264)
Browse files Browse the repository at this point in the history
fixes: #11954
  • Loading branch information
cfc4n authored Sep 25, 2020
1 parent 205a656 commit 8c192d9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions clientv3/retry_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ func (c *Client) streamClientInterceptor(logger *zap.Logger, optFuncs ...retryOp
intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs)
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
ctx = withVersion(ctx)
// getToken automatically
// TODO(cfc4n): keep this code block, remove codes about getToken in client.go after pr #12165 merged.
if c.authTokenBundle != nil {
// equal to c.Username != "" && c.Password != ""
err := c.getToken(ctx)
if err != nil && rpctypes.Error(err) != rpctypes.ErrAuthNotEnabled {
logger.Error("clientv3/retry_interceptor: getToken failed", zap.Error(err))
return nil, err
}
}
grpcOpts, retryOpts := filterCallOptions(opts)
callOpts := reuseOrNewWithCallOptions(intOpts, retryOpts)
// short circuit for simplicity, and avoiding allocations.
Expand Down

0 comments on commit 8c192d9

Please sign in to comment.