From 22283a26ff8c88d87189b0437b30290a1280879d Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 6 Sep 2023 16:44:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=9C=8D=E5=8A=A1=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/robot.txt | 35 ++++++++++------ modules/robot/modulerobot_gm.go | 34 +++++++++++++++ modules/robot/modulerobot_wtask.go | 5 ++- modules/robot/options.go | 17 ++++---- modules/robot/robot.go | 17 +++++--- modules/robot/robotmgrcomp.go | 1 + modules/robot/statisticalcomp.go | 2 + modules/wtask/api_battlefinish.go | 1 - services/cmd/main.go | 3 +- sys/configure/structs/Game.BuriedCondiData.go | 2 + sys/configure/structs/Game.BuzkashiQteLv.go | 42 +++++++++++++++++++ .../structs/Game.BuzkashiQteLvData.go | 39 +++++++++++++++++ sys/configure/structs/Game.QualifyingData.go | 8 ++-- sys/configure/structs/Tables.go | 7 ++++ 14 files changed, 178 insertions(+), 35 deletions(-) create mode 100644 modules/robot/modulerobot_gm.go create mode 100644 sys/configure/structs/Game.BuzkashiQteLv.go create mode 100644 sys/configure/structs/Game.BuzkashiQteLvData.go diff --git a/bin/robot.txt b/bin/robot.txt index 7bb26ae6a..ddec176fa 100644 --- a/bin/robot.txt +++ b/bin/robot.txt @@ -1,14 +1,23 @@ -RobotTotal:1 -SuccRobot:1 -FailRobot:0 -MessageTotal:9 +机器人总数: 1 +成功数量: 1 +失败数量: 0 +消息总吞吐量: 46 ---消息压测详情---------------------------------------------------------------------------------------------------- -消息名:user.login 请求次数:1 耗时最小:348 ms 耗时最大:348 ms 平均耗时:348.00ms 中位耗时:348.00ms -消息名:sys.funcgetlist 请求次数:1 耗时最小:7 ms 耗时最大:7 ms 平均耗时:7.00 ms 中位耗时:7.00 ms -消息名:hero.list 请求次数:1 耗时最小:4 ms 耗时最大:4 ms 平均耗时:4.00 ms 中位耗时:4.00 ms -消息名:equipment.getlist 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms -消息名:mainline.info 请求次数:1 耗时最小:4 ms 耗时最大:4 ms 平均耗时:4.00 ms 中位耗时:4.00 ms -消息名:user.create 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms -消息名:hero.talentlist 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms -消息名:items.getlist 请求次数:1 耗时最小:3 ms 耗时最大:3 ms 平均耗时:3.00 ms 中位耗时:3.00 ms -消息名:wtask.info 请求次数:1 耗时最小:5 ms 耗时最大:5 ms 平均耗时:5.00 ms 中位耗时:5.00 ms +消息名:wtask.accept 请求次数:12 耗时最小:1 ms 耗时最大:5 ms 平均耗时:2.83 ms 中位耗时:3.00 ms +消息名:wtask.completecondi 请求次数:3 耗时最小:1 ms 耗时最大:5 ms 平均耗时:3.67 ms 中位耗时:5.00 ms +消息名:wtask.finish 请求次数:10 耗时最小:2 ms 耗时最大:19 ms 平均耗时:8.40 ms 中位耗时:9.00 ms +消息名:practice.practice 请求次数:1 耗时最小:6 ms 耗时最大:6 ms 平均耗时:6.00 ms 中位耗时:6.00 ms +消息名:mainline.info 请求次数:1 耗时最小:5 ms 耗时最大:5 ms 平均耗时:5.00 ms 中位耗时:5.00 ms +消息名:sys.funcgetlist 请求次数:1 耗时最小:21 ms 耗时最大:21 ms 平均耗时:21.00ms 中位耗时:21.00ms +消息名:equipment.getlist 请求次数:1 耗时最小:0 ms 耗时最大:0 ms 平均耗时:0.00 ms 中位耗时:0.00 ms +消息名:wtask.info 请求次数:1 耗时最小:0 ms 耗时最大:0 ms 平均耗时:0.00 ms 中位耗时:0.00 ms +消息名:wtask.battlefinish 请求次数:4 耗时最小:1 ms 耗时最大:9 ms 平均耗时:3.50 ms 中位耗时:2.00 ms +消息名:practice.info 请求次数:1 耗时最小:8 ms 耗时最大:8 ms 平均耗时:8.00 ms 中位耗时:8.00 ms +消息名:user.login 请求次数:1 耗时最小:586 ms 耗时最大:586 ms 平均耗时:586.00ms 中位耗时:586.00ms +消息名:user.create 请求次数:1 耗时最小:16 ms 耗时最大:16 ms 平均耗时:16.00ms 中位耗时:16.00ms +消息名:items.getlist 请求次数:1 耗时最小:0 ms 耗时最大:0 ms 平均耗时:0.00 ms 中位耗时:0.00 ms +消息名:sys.funcactivate 请求次数:1 耗时最小:3 ms 耗时最大:3 ms 平均耗时:3.00 ms 中位耗时:3.00 ms +消息名:hero.list 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms +消息名:hero.talentlist 请求次数:1 耗时最小:0 ms 耗时最大:0 ms 平均耗时:0.00 ms 中位耗时:0.00 ms +消息名:wtask.battlestart 请求次数:4 耗时最小:1 ms 耗时最大:4 ms 平均耗时:2.25 ms 中位耗时:2.00 ms +消息名:hero.drawcard 请求次数:1 耗时最小:15 ms 耗时最大:15 ms 平均耗时:15.00ms 中位耗时:15.00ms diff --git a/modules/robot/modulerobot_gm.go b/modules/robot/modulerobot_gm.go new file mode 100644 index 000000000..12a0276d7 --- /dev/null +++ b/modules/robot/modulerobot_gm.go @@ -0,0 +1,34 @@ +package robot + +import ( + cfg "go_dreamfactory/sys/configure/structs" + + "google.golang.org/protobuf/proto" +) + +//用户模块 机器人 +type ModuleRobot_GM struct { +} + +func (this *ModuleRobot_GM) Init() (err error) { + + return +} + +//接收到消息 +func (this *ModuleRobot_GM) Receive(robot IRobot, stype string, message proto.Message) (err error) { + + return +} + +//机器人执行流 +func (this *ModuleRobot_GM) DoPipeline(robot IRobot) (err error) { + + return +} + +//做任务 +func (this *ModuleRobot_GM) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { + + return +} diff --git a/modules/robot/modulerobot_wtask.go b/modules/robot/modulerobot_wtask.go index 07b37ba08..95357c4f9 100644 --- a/modules/robot/modulerobot_wtask.go +++ b/modules/robot/modulerobot_wtask.go @@ -145,12 +145,13 @@ locp: case comm.Rtype104: module = comm.ModuleShop default: - log.Error("[Robot DoTask]", log.Field{Key: "ctype", Value: cconf.Type}, log.Field{Key: "conld", Value: cconf.Id}, log.Field{Key: "err", Value: "Not Achieved !"}) + err = fmt.Errorf("[Robot DoTask] ctype:%d conld:%d Not Achieved !", cconf.Type, cconf.Id) + // log.Error("[Robot DoTask]", log.Field{Key: "ctype", Value: cconf.Type}, log.Field{Key: "conld", Value: cconf.Id}, log.Field{Key: "err", Value: "Not Achieved !"}) break locp } if err = robot.DoTask(tconf, cconf, module); err != nil { - log.Error("[Robot DoTask]", log.Field{Key: "task", Value: tconf.Key}, log.Field{Key: "conld", Value: cconf.Id}, log.Field{Key: "err", Value: err.Error()}) + // log.Error("[Robot DoTask]", log.Field{Key: "task", Value: tconf.Key}, log.Field{Key: "conld", Value: cconf.Id}, log.Field{Key: "err", Value: err.Error()}) break locp } time.Sleep(time.Second * 2) diff --git a/modules/robot/options.go b/modules/robot/options.go index fe979b378..70ae49343 100644 --- a/modules/robot/options.go +++ b/modules/robot/options.go @@ -8,14 +8,15 @@ import ( type ( Options struct { modules.Options - OutFilePath string //输出文件报表 - ServerAddr string //服务地址 - ServerID string //服务ID - RobotTotalNum int32 //机器人总数 - RobotSingleNum int32 //单词机器人进入数量 - Intervals int32 //间隔时间 单位秒 - RobotName string //机器人名称 - RobotStart int32 //机器人初始下标 + OutFilePath string //输出文件报表 + ServerAddr string //服务地址 + ServerID string //服务ID + RobotTotalNum int32 //机器人总数 + RobotSingleNum int32 //单词机器人进入数量 + Intervals int32 //间隔时间 单位秒 + RobotName string //机器人名称 + RobotStart int32 //机器人初始下标 + RobotLog bool Pipeline []string //执行流水线 } ) diff --git a/modules/robot/robot.go b/modules/robot/robot.go index 54816ca53..48d86f852 100644 --- a/modules/robot/robot.go +++ b/modules/robot/robot.go @@ -25,6 +25,7 @@ type RobotStatistics struct { type Robot struct { Client monitor IRobotMonitor + debug bool index int32 //编号 account, serverId string curreq string //当前请求 @@ -54,6 +55,7 @@ func (this *Robot) Init(addr string, client IClient) (err error) { this.statistics = make([]*RobotStatistics, 0, 100) this.modules[comm.ModuleUser] = new(ModuleRobot_User) this.modules[comm.ModuleSys] = new(ModuleRobot_Sys) + this.modules[comm.ModuleGM] = new(ModuleRobot_GM) this.modules[comm.ModuleHero] = new(ModuleRobot_Hero) this.modules[comm.ModuleEquipment] = new(ModuleRobot_Equipment) this.modules[comm.ModuleItems] = new(ModuleRobot_Item) @@ -154,7 +156,9 @@ func (this *Robot) SendMessage(mtype, stype string, msg proto.Message) (resp pro message: fmt.Sprintf("%s.%s", mtype, stype), time: time.Since(stime).Milliseconds(), }) - // log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "resp", Value: errdata == nil}) + if this.debug { + log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "resp", Value: errdata == nil}) + } } return } @@ -185,11 +189,14 @@ func (this *Robot) SendTaskMessage(task, comdi int32, mtype, stype string, msg p messageresp = <-this.await //等待回应 resp = messageresp.resp errdata = messageresp.errdata - if errdata == nil { - log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "Task", Value: fmt.Sprintf("[%d-%d]", task, comdi)}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata == nil}) - } else { - log.Error("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "Task", Value: fmt.Sprintf("[%d-%d]", task, comdi)}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata.String()}) + if this.debug { + if errdata == nil { + log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "Task", Value: fmt.Sprintf("[%d-%d]", task, comdi)}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata == nil}) + } else { + log.Error("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "Task", Value: fmt.Sprintf("[%d-%d]", task, comdi)}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata.String()}) + } } + this.statistics = append(this.statistics, &RobotStatistics{ message: fmt.Sprintf("%s.%s", mtype, stype), time: time.Since(stime).Milliseconds(), diff --git a/modules/robot/robotmgrcomp.go b/modules/robot/robotmgrcomp.go index 9a1855dd9..fcbceffb7 100644 --- a/modules/robot/robotmgrcomp.go +++ b/modules/robot/robotmgrcomp.go @@ -60,6 +60,7 @@ func (this *robotmgrComp) createRobot(index int32) { err error ) robot = &Robot{ + debug: this.module.options.RobotLog, monitor: this.module.statisticalComp, index: index, account: fmt.Sprintf("%s_%d", this.module.options.RobotName, this.module.options.RobotStart+index), diff --git a/modules/robot/statisticalcomp.go b/modules/robot/statisticalcomp.go index b2e8ae459..7039eb3df 100644 --- a/modules/robot/statisticalcomp.go +++ b/modules/robot/statisticalcomp.go @@ -4,6 +4,7 @@ import ( "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" + "go_dreamfactory/lego/sys/log" "os" "sort" "sync" @@ -100,4 +101,5 @@ func (this *statisticalComp) OutReport() { } file.WriteString(fmt.Sprintf("消息名:%-20s 请求次数:%-5d 耗时最小:%-5dms 耗时最大:%-5dms 平均耗时:%-5.2fms 中位耗时:%-5.2fms \n", message, len(data), min, max, avg, median)) } + log.Debugf("机器人报表已输出!") } diff --git a/modules/wtask/api_battlefinish.go b/modules/wtask/api_battlefinish.go index 2615f861b..4954d8954 100644 --- a/modules/wtask/api_battlefinish.go +++ b/modules/wtask/api_battlefinish.go @@ -92,7 +92,6 @@ func (this *apiComp) BattleFinish(session comm.IUserSession, req *pb.WTaskBattle } //触发任务 go this.module.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype70, 1, req.BattleConfId)) - } else { go this.module.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype227, 1, req.BattleConfId)) } diff --git a/services/cmd/main.go b/services/cmd/main.go index b25b6dccf..455c69efd 100644 --- a/services/cmd/main.go +++ b/services/cmd/main.go @@ -353,9 +353,8 @@ func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip str "Alias": sseting.Id, "FileName": fmt.Sprintf("./log/%s.log", sseting.Id), "IsDebug": false, - "Loglevel": log.ErrorLevel, + "Loglevel": log.InfoLevel, "MaxAgeTime": 7, - "UniqueLog": true, } } diff --git a/sys/configure/structs/Game.BuriedCondiData.go b/sys/configure/structs/Game.BuriedCondiData.go index e573c1e75..1843afa85 100644 --- a/sys/configure/structs/Game.BuriedCondiData.go +++ b/sys/configure/structs/Game.BuriedCondiData.go @@ -20,6 +20,7 @@ type GameBuriedCondiData struct { Type int32 Valid int32 Head *Gameatn + NpcEventType int32 NPC int32 Value int32 Filter []int32 @@ -55,6 +56,7 @@ func (_v *GameBuriedCondiData)Deserialize(_buf map[string]interface{}) (err erro { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ { err = errors.New("type error"); return }; _v.Type = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["valid"].(float64); !_ok_ { err = errors.New("valid error"); return }; _v.Valid = int32(_tempNum_) } { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["head"].(map[string]interface{}); !_ok_ { err = errors.New("head error"); return }; if _v.Head, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["Npc_event_type"].(float64); !_ok_ { err = errors.New("Npc_event_type error"); return }; _v.NpcEventType = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["NPC"].(float64); !_ok_ { err = errors.New("NPC error"); return }; _v.NPC = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["value"].(float64); !_ok_ { err = errors.New("value error"); return }; _v.Value = int32(_tempNum_) } { diff --git a/sys/configure/structs/Game.BuzkashiQteLv.go b/sys/configure/structs/Game.BuzkashiQteLv.go new file mode 100644 index 000000000..799fa033b --- /dev/null +++ b/sys/configure/structs/Game.BuzkashiQteLv.go @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +type GameBuzkashiQteLv struct { + _dataMap map[int32]*GameBuzkashiQteLvData + _dataList []*GameBuzkashiQteLvData +} + +func NewGameBuzkashiQteLv(_buf []map[string]interface{}) (*GameBuzkashiQteLv, error) { + _dataList := make([]*GameBuzkashiQteLvData, 0, len(_buf)) + dataMap := make(map[int32]*GameBuzkashiQteLvData) + for _, _ele_ := range _buf { + if _v, err2 := DeserializeGameBuzkashiQteLvData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Num] = _v + } + } + return &GameBuzkashiQteLv{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *GameBuzkashiQteLv) GetDataMap() map[int32]*GameBuzkashiQteLvData { + return table._dataMap +} + +func (table *GameBuzkashiQteLv) GetDataList() []*GameBuzkashiQteLvData { + return table._dataList +} + +func (table *GameBuzkashiQteLv) Get(key int32) *GameBuzkashiQteLvData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/Game.BuzkashiQteLvData.go b/sys/configure/structs/Game.BuzkashiQteLvData.go new file mode 100644 index 000000000..223df62d2 --- /dev/null +++ b/sys/configure/structs/Game.BuzkashiQteLvData.go @@ -0,0 +1,39 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +import "errors" + +type GameBuzkashiQteLvData struct { + Num int32 + Time float32 + Value int32 +} + +const TypeId_GameBuzkashiQteLvData = 795602659 + +func (*GameBuzkashiQteLvData) GetTypeId() int32 { + return 795602659 +} + +func (_v *GameBuzkashiQteLvData)Deserialize(_buf map[string]interface{}) (err error) { + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["num"].(float64); !_ok_ { err = errors.New("num error"); return }; _v.Num = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["time"].(float64); !_ok_ { err = errors.New("time error"); return }; _v.Time = float32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["value"].(float64); !_ok_ { err = errors.New("value error"); return }; _v.Value = int32(_tempNum_) } + return +} + +func DeserializeGameBuzkashiQteLvData(_buf map[string]interface{}) (*GameBuzkashiQteLvData, error) { + v := &GameBuzkashiQteLvData{} + if err := v.Deserialize(_buf); err == nil { + return v, nil + } else { + return nil, err + } +} diff --git a/sys/configure/structs/Game.QualifyingData.go b/sys/configure/structs/Game.QualifyingData.go index 1e404ade9..914741079 100644 --- a/sys/configure/structs/Game.QualifyingData.go +++ b/sys/configure/structs/Game.QualifyingData.go @@ -19,8 +19,8 @@ type GameQualifyingData struct { MatefailReward []*Gameatn RankwinReward []*Gameatn RankfailReward []*Gameatn - WinValue float32 - FailValue float32 + WinValue int32 + FailValue int32 SettlementReward []*Gameatn Png string } @@ -92,8 +92,8 @@ func (_v *GameQualifyingData)Deserialize(_buf map[string]interface{}) (err error } } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["win_value"].(float64); !_ok_ { err = errors.New("win_value error"); return }; _v.WinValue = float32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["fail_value"].(float64); !_ok_ { err = errors.New("fail_value error"); return }; _v.FailValue = float32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["win_value"].(float64); !_ok_ { err = errors.New("win_value error"); return }; _v.WinValue = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["fail_value"].(float64); !_ok_ { err = errors.New("fail_value error"); return }; _v.FailValue = int32(_tempNum_) } { var _arr_ []interface{} var _ok_ bool diff --git a/sys/configure/structs/Tables.go b/sys/configure/structs/Tables.go index f0afb2ae8..de5f8e068 100644 --- a/sys/configure/structs/Tables.go +++ b/sys/configure/structs/Tables.go @@ -176,6 +176,7 @@ type Tables struct { Navigation *GameNavigation BuzkashiMount *GameBuzkashiMount BuzkashiLv *GameBuzkashiLv + BuzkashiQteLv *GameBuzkashiQteLv BuzkashiGrade *GameBuzkashiGrade BuzkashiReward *GameBuzkashiReward BuzkashiFm *GameBuzkashiFm @@ -1255,6 +1256,12 @@ func NewTables(loader JsonLoader) (*Tables, error) { if tables.BuzkashiLv, err = NewGameBuzkashiLv(buf) ; err != nil { return nil, err } + if buf, err = loader("game_buzkashiqtelv") ; err != nil { + return nil, err + } + if tables.BuzkashiQteLv, err = NewGameBuzkashiQteLv(buf) ; err != nil { + return nil, err + } if buf, err = loader("game_buzkashigrade") ; err != nil { return nil, err }