24 lines
640 B
Go
24 lines
640 B
Go
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"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func ThirdPartyNewClient(sid ...int64) (rspb.ThirdPartyClient, error) {
|
|
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
|
|
}
|
|
return rspb.NewThirdPartyClient(c), nil
|
|
}
|