1 Star 0 Fork 1

Samlily-Xie/RPC-Turbo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
grpcclient.go 806 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiaozhang 提交于 2018-09-30 16:09 +08:00 . support multiple client
/*
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file.
*/
package turbo
import (
"google.golang.org/grpc"
)
type grpcClient struct {
grpcServiceMap map[string]interface{}
conn *grpc.ClientConn
}
func (g *grpcClient) init(addr string, clientCreator grpcClientCreator) {
// ???? support grpcservice discovery
if g.grpcServiceMap != nil {
return
}
log.Info("[grpc]connecting addr:", addr)
g.dial(addr)
g.grpcServiceMap = clientCreator(g.conn)
}
func (g *grpcClient) dial(address string) {
var err error
g.conn, err = grpc.Dial(address, grpc.WithInsecure())
logPanicIf(err)
}
func (g *grpcClient) close() error {
if g.conn == nil {
return nil
}
return g.conn.Close()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/samlily-xie/RPC-Turbo.git
git@gitee.com:samlily-xie/RPC-Turbo.git
samlily-xie
RPC-Turbo
RPC-Turbo
master

搜索帮助