本文整理匯總了Golang中github.com/cockroachdb/cockroach/base.Context.GetClientTLSConfig方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.GetClientTLSConfig方法的具體用法?Golang Context.GetClientTLSConfig怎麽用?Golang Context.GetClientTLSConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/base.Context
的用法示例。
在下文中一共展示了Context.GetClientTLSConfig方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newRPCSender
// newRPCSender returns a new instance of rpcSender.
func newRPCSender(server string, context *base.Context, retryOpts retry.Options) (*rpcSender, error) {
addr, err := net.ResolveTCPAddr("tcp", server)
if err != nil {
return nil, err
}
tlsConfig, err := context.GetClientTLSConfig()
if err != nil {
return nil, err
}
conn, err := codec.TLSDialHTTP(addr.Network(), addr.String(), base.NetworkTimeout, tlsConfig)
if err != nil {
return nil, err
}
client := rpc.NewClientWithCodec(codec.NewClientCodec(conn))
return &rpcSender{
user: context.User,
client: client,
retryOpts: retryOpts,
}, nil
}
示例2: newRPCSender
// newRPCSender returns a new instance of rpcSender.
func newRPCSender(server string, context *base.Context, retryOpts retry.Options, stopper *stop.Stopper) (*rpcSender, error) {
addr, err := net.ResolveTCPAddr("tcp", server)
if err != nil {
return nil, err
}
if context.Insecure {
log.Warning("running in insecure mode, this is strongly discouraged. See --insecure and --certs.")
} else {
if _, err := context.GetClientTLSConfig(); err != nil {
return nil, err
}
}
ctx := rpc.NewContext(context, hlc.NewClock(hlc.UnixNano), stopper)
client := rpc.NewClient(addr, ctx)
return &rpcSender{
client: client,
retryOpts: retryOpts,
}, nil
}