fix
This commit is contained in:
parent
537de58afc
commit
77066ec392
|
@ -61,6 +61,7 @@ func (l *GetStatLogic) GetStat(req *types.GetStatReq, userinfo *auth.UserInfo) (
|
||||||
CurCombineCount: curCombineTotalCount,
|
CurCombineCount: curCombineTotalCount,
|
||||||
CurUnityHandleCount: curUnityHandleTotalCount,
|
CurUnityHandleCount: curUnityHandleTotalCount,
|
||||||
CombineErrorCount: combineErrTotalCount,
|
CombineErrorCount: combineErrTotalCount,
|
||||||
|
UnityErrorCount: unityErrTotalCount,
|
||||||
UserWsStat: userStat,
|
UserWsStat: userStat,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,10 +49,6 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
||||||
logx.Error("渲染回调参数错误:任务标识")
|
logx.Error("渲染回调参数错误:任务标识")
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
||||||
}
|
}
|
||||||
if req.Image == "" {
|
|
||||||
logx.Error("渲染回调参数错误:渲染结果图片数据")
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
|
|
||||||
}
|
|
||||||
unityRenderEndTime := time.Now().UTC().UnixMilli()
|
unityRenderEndTime := time.Now().UTC().UnixMilli()
|
||||||
//解析数据
|
//解析数据
|
||||||
var info websocket_data.ToUnityIdStruct
|
var info websocket_data.ToUnityIdStruct
|
||||||
|
@ -121,6 +117,8 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
||||||
}
|
}
|
||||||
//发送错误信息给前端
|
//发送错误信息给前端
|
||||||
ws.renderErrResponse(requestId, info.TemplateTag, info.TaskId, "unity云渲染错误:"+req.Msg, 0, 0, 0, 0, 0, 0, 0)
|
ws.renderErrResponse(requestId, info.TemplateTag, info.TaskId, "unity云渲染错误:"+req.Msg, 0, 0, 0, 0, 0, 0, 0)
|
||||||
|
//统计unity处理数
|
||||||
|
increaseUnityErrorCount(req.UserId, req.GuestId)
|
||||||
logx.Info("渲染失败且发送了失败信息")
|
logx.Info("渲染失败且发送了失败信息")
|
||||||
} else {
|
} else {
|
||||||
logx.Info("渲染失败且找不到ws连接")
|
logx.Info("渲染失败且找不到ws连接")
|
||||||
|
|
|
@ -15,6 +15,7 @@ const (
|
||||||
TYPE_CUR_COMBINE_IMAGE_COUNT websocketStatType = "TYPE_CUR_COMBINE_IMAGE_COUNT" //合图数
|
TYPE_CUR_COMBINE_IMAGE_COUNT websocketStatType = "TYPE_CUR_COMBINE_IMAGE_COUNT" //合图数
|
||||||
TYPE_CUR_COMBINE_IMAGE_ERR_COUNT websocketStatType = "TYPE_CUR_COMBINE_IMAGE_ERR_COUNT" //合图失败数
|
TYPE_CUR_COMBINE_IMAGE_ERR_COUNT websocketStatType = "TYPE_CUR_COMBINE_IMAGE_ERR_COUNT" //合图失败数
|
||||||
TYPE_CUR_UNITY_HANDLE_COUNT websocketStatType = "TYPE_CUR_UNITY_HANDLE_COUNT" //unity处理数
|
TYPE_CUR_UNITY_HANDLE_COUNT websocketStatType = "TYPE_CUR_UNITY_HANDLE_COUNT" //unity处理数
|
||||||
|
TYPE_UNITY_ERR_COUNT websocketStatType = "TYPE_UNITY_ERR_COUNT" //unity错误处理数
|
||||||
)
|
)
|
||||||
|
|
||||||
type websocketStatData struct {
|
type websocketStatData struct {
|
||||||
|
@ -28,6 +29,7 @@ type mapUserWsStatItem struct {
|
||||||
CombineErrCount int `json:"combine_err_count"` //合图失败数
|
CombineErrCount int `json:"combine_err_count"` //合图失败数
|
||||||
CurWsConnectCount int `json:"cur_ws_connect_count"` //当前连接数
|
CurWsConnectCount int `json:"cur_ws_connect_count"` //当前连接数
|
||||||
CurUnityHandleCount int `json:"cur_unity_handle_count"` //当前unity处理数
|
CurUnityHandleCount int `json:"cur_unity_handle_count"` //当前unity处理数
|
||||||
|
UnityErrCount int `json:"unity_err_count"` //unity处理错误数
|
||||||
}
|
}
|
||||||
|
|
||||||
// 统计信息
|
// 统计信息
|
||||||
|
@ -42,6 +44,8 @@ var (
|
||||||
combineErrTotalCount int
|
combineErrTotalCount int
|
||||||
//unity正在渲染总数
|
//unity正在渲染总数
|
||||||
curUnityHandleTotalCount int
|
curUnityHandleTotalCount int
|
||||||
|
//unity错误统计数
|
||||||
|
unityErrTotalCount int
|
||||||
//算法正在合图总数
|
//算法正在合图总数
|
||||||
curCombineTotalCount int
|
curCombineTotalCount int
|
||||||
)
|
)
|
||||||
|
@ -155,7 +159,7 @@ func increaseUnityRequestCount(userId, guestId int64) {
|
||||||
curUnityHandleTotalCount += data.Num
|
curUnityHandleTotalCount += data.Num
|
||||||
return
|
return
|
||||||
case <-time.After(time.Millisecond * 200):
|
case <-time.After(time.Millisecond * 200):
|
||||||
logx.Error("decreaseCombineRequestCount 输入管道超时,丢弃消息")
|
logx.Error("increaseUnityRequestCount 输入管道超时,丢弃消息")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,6 +185,24 @@ func decreaseUnityRequestCount(userId, guestId int64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 累曾unity错误统计
|
||||||
|
func increaseUnityErrorCount(userId, guestId int64) {
|
||||||
|
data := websocketStatData{
|
||||||
|
UserId: userId,
|
||||||
|
GuestId: guestId,
|
||||||
|
Type: TYPE_UNITY_ERR_COUNT,
|
||||||
|
Num: 1,
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case websocketStat <- data:
|
||||||
|
unityErrTotalCount += data.Num
|
||||||
|
return
|
||||||
|
case <-time.After(time.Millisecond * 200):
|
||||||
|
logx.Error("increaseUnityErrorCount 输入管道超时,丢弃消息")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 消费数据
|
// 消费数据
|
||||||
func ConsumeWebsocketStatData(ctx context.Context) {
|
func ConsumeWebsocketStatData(ctx context.Context) {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -266,6 +288,19 @@ func ConsumeWebsocketStatData(ctx context.Context) {
|
||||||
stat.CombineErrCount += data.Num
|
stat.CombineErrCount += data.Num
|
||||||
//保存统计
|
//保存统计
|
||||||
mapUserWsStat.Store(key, stat)
|
mapUserWsStat.Store(key, stat)
|
||||||
|
case TYPE_UNITY_ERR_COUNT: //unity错误信息
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
//存在
|
||||||
|
stat, ok := statData.(mapUserWsStatItem)
|
||||||
|
if !ok {
|
||||||
|
logx.Error("断言mapUserWsStatItem错误")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
stat.UnityErrCount += data.Num
|
||||||
|
//保存统计
|
||||||
|
mapUserWsStat.Store(key, stat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ type GetStatRsp struct {
|
||||||
CurCombineCount int `json:"cur_combine_count"` //合图任务数
|
CurCombineCount int `json:"cur_combine_count"` //合图任务数
|
||||||
CombineErrorCount int `json:"combine_error_count"` //合图失败数
|
CombineErrorCount int `json:"combine_error_count"` //合图失败数
|
||||||
CurUnityHandleCount int `json:"cur_unity_handle_count"` //当前unity请求总数
|
CurUnityHandleCount int `json:"cur_unity_handle_count"` //当前unity请求总数
|
||||||
|
UnityErrorCount int `json:"unity_error_count"` //unity错误统计
|
||||||
UserWsStat interface{} `json:"user_ws_stat"` //用户连接统计
|
UserWsStat interface{} `json:"user_ws_stat"` //用户连接统计
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,5 +60,6 @@ type GetStatRsp {
|
||||||
CurCombineCount int `json:"cur_combine_count"` //合图任务数
|
CurCombineCount int `json:"cur_combine_count"` //合图任务数
|
||||||
CombineErrorCount int `json:"combine_error_count"` //合图失败数
|
CombineErrorCount int `json:"combine_error_count"` //合图失败数
|
||||||
CurUnityHandleCount int `json:"cur_unity_handle_count"` //当前unity请求总数
|
CurUnityHandleCount int `json:"cur_unity_handle_count"` //当前unity请求总数
|
||||||
|
UnityErrorCount int `json:"unity_error_count"` //unity错误统计
|
||||||
UserWsStat interface{} `json:"user_ws_stat"` //用户连接统计
|
UserWsStat interface{} `json:"user_ws_stat"` //用户连接统计
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user