perf与性能优化

This commit is contained in:
flswld
2023-04-15 20:00:37 +08:00
parent 149b773f4b
commit 094ad5add0
26 changed files with 403 additions and 308 deletions

View File

@@ -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)

View File

@@ -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