mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
perf与性能优化
This commit is contained in:
@@ -22,13 +22,13 @@ func Run(ctx context.Context, configFile string) error {
|
||||
config.InitConfig(configFile)
|
||||
|
||||
// natsrpc client
|
||||
client, err := rpc.NewClient()
|
||||
discoveryClient, err := rpc.NewDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 注册到节点服务器
|
||||
rsp, err := client.Discovery.RegisterServer(context.TODO(), &api.RegisterServerReq{
|
||||
rsp, err := discoveryClient.RegisterServer(context.TODO(), &api.RegisterServerReq{
|
||||
ServerType: api.PATHFINDING,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -39,7 +39,7 @@ func Run(ctx context.Context, configFile string) error {
|
||||
ticker := time.NewTicker(time.Second * 15)
|
||||
for {
|
||||
<-ticker.C
|
||||
_, err := client.Discovery.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
|
||||
_, err := discoveryClient.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
|
||||
ServerType: api.PATHFINDING,
|
||||
AppId: APPID,
|
||||
})
|
||||
@@ -49,7 +49,7 @@ func Run(ctx context.Context, configFile string) error {
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
_, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{
|
||||
_, _ = discoveryClient.CancelServer(context.TODO(), &api.CancelServerReq{
|
||||
ServerType: api.PATHFINDING,
|
||||
AppId: APPID,
|
||||
})
|
||||
@@ -61,7 +61,7 @@ func Run(ctx context.Context, configFile string) error {
|
||||
logger.CloseLogger()
|
||||
}()
|
||||
|
||||
messageQueue := mq.NewMessageQueue(api.PATHFINDING, APPID, client)
|
||||
messageQueue := mq.NewMessageQueue(api.PATHFINDING, APPID, discoveryClient)
|
||||
defer messageQueue.Close()
|
||||
|
||||
_ = handle.NewHandle(messageQueue)
|
||||
|
||||
@@ -55,7 +55,8 @@ func (h *Handle) QueryPath(userId uint32, gateAppId string, payloadMsg pb.Messag
|
||||
if !ok {
|
||||
queryPathRsp := &proto.QueryPathRsp{
|
||||
QueryId: req.QueryId,
|
||||
QueryStatus: proto.QueryPathRsp_STATUS_FAIL,
|
||||
QueryStatus: proto.QueryPathRsp_STATUS_SUCC,
|
||||
Corners: []*proto.Vector{req.DestinationPos[0]},
|
||||
}
|
||||
h.SendMsg(cmd.QueryPathRsp, userId, gateAppId, queryPathRsp)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user