This commit is contained in:
laodaming 2023-11-02 15:21:12 +08:00
parent ea859786da
commit f167aad093

View File

@ -61,7 +61,6 @@ func increaseWebsocketConnectCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
curWsTotalCount += data.Num
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("increaseWebsocketConnectCount 输入管道超时,丢弃消息") logx.Error("increaseWebsocketConnectCount 输入管道超时,丢弃消息")
@ -79,10 +78,6 @@ func decreaseWebsocketConnectCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
curWsTotalCount += data.Num
if curWsTotalCount < 0 {
curWsTotalCount = 0
}
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("decreaseWebsocketConnectCount 输入管道超时,丢弃消息") logx.Error("decreaseWebsocketConnectCount 输入管道超时,丢弃消息")
@ -100,7 +95,6 @@ func increaseCombineRequestCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
curCombineTotalCount += data.Num
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("increaseCombineRequestCount 输入管道超时,丢弃消息") logx.Error("increaseCombineRequestCount 输入管道超时,丢弃消息")
@ -118,10 +112,6 @@ func decreaseCombineRequestCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
curCombineTotalCount += data.Num
if curCombineTotalCount < 0 {
curCombineTotalCount = 0
}
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("decreaseCombineRequestCount 输入管道超时,丢弃消息") logx.Error("decreaseCombineRequestCount 输入管道超时,丢弃消息")
@ -139,7 +129,6 @@ func increaseCombineRequestErrorCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
combineErrTotalCount += data.Num
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("increaseCombineRequestErrorCount 输入管道超时,丢弃消息") logx.Error("increaseCombineRequestErrorCount 输入管道超时,丢弃消息")
@ -157,7 +146,6 @@ func increaseUnityRequestCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
curUnityHandleTotalCount += data.Num
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("increaseUnityRequestCount 输入管道超时,丢弃消息") logx.Error("increaseUnityRequestCount 输入管道超时,丢弃消息")
@ -175,10 +163,6 @@ func decreaseUnityRequestCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
curUnityHandleTotalCount += data.Num
if curUnityHandleTotalCount < 0 {
curUnityHandleTotalCount = 0
}
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("decreaseUnityRequestCount 输入管道超时,丢弃消息") logx.Error("decreaseUnityRequestCount 输入管道超时,丢弃消息")
@ -196,7 +180,6 @@ func increaseUnityErrorCount(userId, guestId int64) {
} }
select { select {
case websocketStat <- data: case websocketStat <- data:
unityErrTotalCount += data.Num
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
logx.Error("increaseUnityErrorCount 输入管道超时,丢弃消息") logx.Error("increaseUnityErrorCount 输入管道超时,丢弃消息")
@ -218,6 +201,7 @@ func ConsumeWebsocketStatData() {
statData, ok := mapUserWsStat.Load(key) statData, ok := mapUserWsStat.Load(key)
switch data.Type { switch data.Type {
case TYPE_CUR_CONNECT_COUNT: //ws连接计数 case TYPE_CUR_CONNECT_COUNT: //ws连接计数
curWsTotalCount += data.Num
if !ok { if !ok {
mapUserWsStat.Store(key, mapUserWsStatItem{ mapUserWsStat.Store(key, mapUserWsStatItem{
CurWsConnectCount: data.Num, CurWsConnectCount: data.Num,
@ -238,6 +222,7 @@ func ConsumeWebsocketStatData() {
//保存统计 //保存统计
mapUserWsStat.Store(key, stat) mapUserWsStat.Store(key, stat)
case TYPE_CUR_COMBINE_IMAGE_COUNT: //请求算法合图计数 case TYPE_CUR_COMBINE_IMAGE_COUNT: //请求算法合图计数
curCombineTotalCount += data.Num
//不存在 //不存在
if !ok { if !ok {
continue continue
@ -255,6 +240,7 @@ func ConsumeWebsocketStatData() {
//保存统计 //保存统计
mapUserWsStat.Store(key, stat) mapUserWsStat.Store(key, stat)
case TYPE_CUR_UNITY_HANDLE_COUNT: //unity处理计数 case TYPE_CUR_UNITY_HANDLE_COUNT: //unity处理计数
curUnityHandleTotalCount += data.Num
if !ok { if !ok {
continue continue
} }
@ -265,12 +251,13 @@ func ConsumeWebsocketStatData() {
continue continue
} }
stat.CurUnityHandleCount += data.Num stat.CurUnityHandleCount += data.Num
if stat.CurUnityHandleCount <= 0 { if stat.CurUnityHandleCount < 0 {
stat.CurUnityHandleCount = 0 stat.CurUnityHandleCount = 0
} }
//保存统计 //保存统计
mapUserWsStat.Store(key, stat) mapUserWsStat.Store(key, stat)
case TYPE_CUR_COMBINE_IMAGE_ERR_COUNT: //合图失败计数 case TYPE_CUR_COMBINE_IMAGE_ERR_COUNT: //合图失败计数
combineErrTotalCount += data.Num
if !ok { if !ok {
continue continue
} }
@ -284,6 +271,7 @@ func ConsumeWebsocketStatData() {
//保存统计 //保存统计
mapUserWsStat.Store(key, stat) mapUserWsStat.Store(key, stat)
case TYPE_UNITY_ERR_COUNT: //unity错误信息 case TYPE_UNITY_ERR_COUNT: //unity错误信息
unityErrTotalCount += data.Num
if !ok { if !ok {
continue continue
} }