feat 初始化
This commit is contained in:
@@ -5,18 +5,17 @@ import (
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func ThirdPartyNewClient(sid ...int64) (rspb.ThirdPartyClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverThirdParty, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewThirdPartyClient(c), nil
|
||||
}
|
||||
|
||||
func ThirdPartyNewClientLB() (rspb.ThirdPartyClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameThirdParty)
|
||||
var c *grpc.ClientConn
|
||||
var err error
|
||||
if len(sid) == 0 {
|
||||
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameThirdParty)
|
||||
} else {
|
||||
c, err = discover.FindServer(common.KeyDiscoverThirdParty, sid...)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user