feat grpc客户端整理
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
)
|
||||
|
||||
func GatewayNewClient(sid ...string) (grpc_pb.GatewayClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return grpc_pb.NewGatewayClient(c), nil
|
||||
}
|
||||
|
||||
func GatewayNewBroadcastClient() map[string]grpc_pb.GatewayClient {
|
||||
clientM := make(map[string]grpc_pb.GatewayClient)
|
||||
connM := discover.FindServerAll(common.KeyDiscoverGateway)
|
||||
for sid, conn := range connM {
|
||||
clientM[sid] = grpc_pb.NewGatewayClient(conn)
|
||||
}
|
||||
return clientM
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/resolver"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
)
|
||||
|
||||
func QgdzsNewClient(sid ...string) (grpc_pb.QgdzsClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverQgdzs, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return grpc_pb.NewQgdzsClient(c), nil
|
||||
}
|
||||
|
||||
func QgdzsNewClientLB() (grpc_pb.QgdzsClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return grpc_pb.NewQgdzsClient(c), nil
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/resolver"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
)
|
||||
|
||||
func SceneNewClient(sid ...string) (grpc_pb.SceneClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return grpc_pb.NewSceneClient(c), nil
|
||||
}
|
||||
|
||||
func SceneNewClientLB() (grpc_pb.SceneClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return grpc_pb.NewSceneClient(c), nil
|
||||
}
|
||||
|
||||
func SceneNewBroadcastClient() map[string]grpc_pb.SceneClient {
|
||||
clientM := make(map[string]grpc_pb.SceneClient)
|
||||
connM := discover.FindServerAll(common.KeyDiscoverScene)
|
||||
for sid, conn := range connM {
|
||||
clientM[sid] = grpc_pb.NewSceneClient(conn)
|
||||
}
|
||||
return clientM
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/resolver"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
)
|
||||
|
||||
func UserNewClient(sid ...string) (grpc_pb.UserClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverUser, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return grpc_pb.NewUserClient(c), nil
|
||||
}
|
||||
|
||||
func UserNewClientLB() (grpc_pb.UserClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameUser)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return grpc_pb.NewUserClient(c), nil
|
||||
}
|
||||
Reference in New Issue
Block a user