feat 初始化
This commit is contained in:
24
net/grpc/grpcclient/client_third-party.go
Normal file
24
net/grpc/grpcclient/client_third-party.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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"
|
||||
)
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewThirdPartyClient(c), nil
|
||||
}
|
||||
Reference in New Issue
Block a user