feat 初始化
This commit is contained in:
23
net/grpc/grpcclient/client_timer.go
Normal file
23
net/grpc/grpcclient/client_timer.go
Normal file
@@ -0,0 +1,23 @@
|
||||
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 TimerNewClient(sid ...int64) (rspb.TimerClient, error) {
|
||||
var c *grpc.ClientConn
|
||||
var err error
|
||||
if len(sid) == 0 {
|
||||
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameTimer)
|
||||
} else {
|
||||
c, err = discover.FindServer(common.KeyDiscoverTimer, sid...)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewTimerClient(c), nil
|
||||
}
|
||||
Reference in New Issue
Block a user