fix
This commit is contained in:
parent
ef53f59551
commit
ac07b86971
|
@ -93,37 +93,44 @@ func ConsumeWebsocketStatData(ctx context.Context) {
|
||||||
switch data.Type {
|
switch data.Type {
|
||||||
case TYPE_CONNECT_COUNT: //ws连接计数
|
case TYPE_CONNECT_COUNT: //ws连接计数
|
||||||
statData, ok := mapUserWsStat.Load(key)
|
statData, ok := mapUserWsStat.Load(key)
|
||||||
if ok { //存在就累加
|
if !ok {
|
||||||
if stat, ok := statData.(mapUserWsStatItem); ok {
|
if data.Value <= 0 {
|
||||||
stat.CurWsConnectCount += data.Value
|
continue
|
||||||
if stat.CurWsConnectCount == 0 { //为0则移除
|
|
||||||
mapUserWsStat.Delete(key)
|
|
||||||
} else {
|
|
||||||
mapUserWsStat.Store(key, stat)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
logx.Error("断言mapUserWsStatItem错误")
|
|
||||||
}
|
|
||||||
} else { //不存在就赋值
|
|
||||||
mapUserWsStat.Store(key, mapUserWsStatItem{
|
mapUserWsStat.Store(key, mapUserWsStatItem{
|
||||||
CurWsConnectCount: data.Value,
|
CurWsConnectCount: data.Value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
stat, ok := statData.(mapUserWsStatItem)
|
||||||
|
if !ok {
|
||||||
|
logx.Error("断言mapUserWsStatItem错误")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
stat.CurWsConnectCount += data.Value
|
||||||
|
if stat.CurWsConnectCount <= 0 { //小于等于0则移除
|
||||||
|
mapUserWsStat.Delete(key)
|
||||||
|
} else {
|
||||||
|
mapUserWsStat.Store(key, stat)
|
||||||
|
}
|
||||||
case TYPE_COMBINE_IMAGE_REQUEST_COUNT: //请求算法合图计数
|
case TYPE_COMBINE_IMAGE_REQUEST_COUNT: //请求算法合图计数
|
||||||
statData, ok := mapUserWsStat.Load(key)
|
statData, ok := mapUserWsStat.Load(key)
|
||||||
if ok { //存在就累加
|
if !ok {
|
||||||
if stat, ok := statData.(mapUserWsStatItem); ok {
|
if data.Value > 0 {
|
||||||
stat.CurCombineCount += data.Value
|
|
||||||
mapUserWsStat.Store(key, stat)
|
|
||||||
} else {
|
|
||||||
logx.Error("断言mapUserWsStatItem错误")
|
|
||||||
}
|
|
||||||
} else { //不存在就赋值
|
|
||||||
mapUserWsStat.Store(key, mapUserWsStatItem{
|
mapUserWsStat.Store(key, mapUserWsStatItem{
|
||||||
CurCombineCount: data.Value,
|
CurCombineCount: data.Value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if stat, ok := statData.(mapUserWsStatItem); ok {
|
||||||
|
stat.CurCombineCount += data.Value
|
||||||
|
if stat.CurCombineCount < 0 {
|
||||||
|
stat.CurCombineCount = 0
|
||||||
|
}
|
||||||
|
mapUserWsStat.Store(key, stat)
|
||||||
|
} else {
|
||||||
|
logx.Error("断言mapUserWsStatItem错误")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user