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