fix: Redis 模式下活跃会话数错误显示为 0,应为不显示
- FallbackStore.Metrics() 未设置 ActiveCount 时 Go 默认值为 0,模板误显示 0 - 修复:Redis 健康时显式设置 ActiveCount=-1,与 RedisStore.Metrics() 一致 - 模板 ge .ActiveSessions 0 判断自动隐藏,Redis 模式不统计会话数(代价高)
This commit is contained in:
@ -252,22 +252,17 @@ func (fs *FallbackStore) Metrics() StoreMetrics {
|
|||||||
m := StoreMetrics{
|
m := StoreMetrics{
|
||||||
Type: "redis",
|
Type: "redis",
|
||||||
Healthy: healthy,
|
Healthy: healthy,
|
||||||
|
ActiveCount: -1, // Redis 模式不统计活跃会话数(代价高),模板 ge 0 判断自动隐藏
|
||||||
}
|
}
|
||||||
|
|
||||||
if !healthy {
|
if !healthy {
|
||||||
m.Type = "memory"
|
m.Type = "memory"
|
||||||
m.Degraded = true
|
m.Degraded = true
|
||||||
|
m.ActiveCount = fs.memory.Metrics().ActiveCount
|
||||||
} else if isDegraded {
|
} else if isDegraded {
|
||||||
m.Degraded = true
|
m.Degraded = true
|
||||||
m.DegradedNote = "Redis 已恢复,但存在历史降级记录(重启后清除)"
|
m.DegradedNote = "Redis 已恢复,但存在历史降级记录(重启后清除)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 活跃会话数:Redis 模式不统计(代价高),Memory 模式可从 memory store 获取
|
|
||||||
if !healthy {
|
|
||||||
if memMetrics := fs.memory.Metrics(); memMetrics.Type == "memory" {
|
|
||||||
m.ActiveCount = memMetrics.ActiveCount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user