feat 初始化
This commit is contained in:
24
net/grpc/grpcclient/client_post.go
Normal file
24
net/grpc/grpcclient/client_post.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 PostNewClient(sid ...int64) (rspb.PostClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverPost, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewPostClient(c), nil
|
||||
}
|
||||
|
||||
func PostNewClientLB() (rspb.PostClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNamePost)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewPostClient(c), nil
|
||||
}
|
||||
Reference in New Issue
Block a user