34 lines
948 B
Go
34 lines
948 B
Go
package grpc_client
|
|
|
|
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 ...int64) (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[int64]grpc_pb.SceneClient {
|
|
clientM := make(map[int64]grpc_pb.SceneClient)
|
|
connM := discover.FindServerAll(common.KeyDiscoverScene)
|
|
for sid, conn := range connM {
|
|
clientM[sid] = grpc_pb.NewSceneClient(conn)
|
|
}
|
|
return clientM
|
|
}
|