feat 初始化
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func QgdzsNewClient(sid ...int64) (rspb.QgdzsClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverQgdzs, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewQgdzsClient(c), nil
|
||||
}
|
||||
|
||||
func QgdzsNewClientLB() (rspb.QgdzsClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
|
||||
var c *grpc.ClientConn
|
||||
var err error
|
||||
if len(sid) == 0 {
|
||||
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
|
||||
} else {
|
||||
c, err = discover.FindServer(common.KeyDiscoverQgdzs, sid...)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user