feat(health): add health check detail to health api

This commit is contained in:
yusing
2025-05-05 13:27:00 +08:00
parent 4df31263b5
commit b090598b68
5 changed files with 33 additions and 0 deletions

View File

@@ -65,6 +65,21 @@ func (w *Watcher) Status() health.Status {
return health.StatusNapping
}
// Detail implements health.HealthMonitor.
func (w *Watcher) Detail() string {
state := w.state.Load()
if state.err != nil {
return state.err.Error()
}
if !state.ready {
return "not ready"
}
if state.status == idlewatcher.ContainerStatusRunning {
return "starting"
}
return "napping"
}
func checkUpdateState(key string) (w *Watcher, ready bool, err error) {
watcherMapMu.RLock()
w, ok := watcherMap[key]