mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-31 06:03:06 +02:00
feat: idle sleep for proxmox LXCs
This commit is contained in:
40
internal/idlewatcher/debug.go
Normal file
40
internal/idlewatcher/debug.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package idlewatcher
|
||||
|
||||
import (
|
||||
"iter"
|
||||
"strconv"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||
)
|
||||
|
||||
type watcherDebug struct {
|
||||
*Watcher
|
||||
}
|
||||
|
||||
func (w watcherDebug) MarshalMap() map[string]any {
|
||||
state := w.state.Load()
|
||||
return map[string]any{
|
||||
"name": w.Name(),
|
||||
"state": map[string]string{
|
||||
"status": string(state.status),
|
||||
"ready": strconv.FormatBool(state.ready),
|
||||
"err": fmtErr(state.err),
|
||||
},
|
||||
"expires": strutils.FormatTime(w.expires()),
|
||||
"last_reset": strutils.FormatTime(w.lastReset.Load()),
|
||||
"config": w.cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func Watchers() iter.Seq2[string, watcherDebug] {
|
||||
return func(yield func(string, watcherDebug) bool) {
|
||||
watcherMapMu.RLock()
|
||||
defer watcherMapMu.RUnlock()
|
||||
|
||||
for k, w := range watcherMap {
|
||||
if !yield(k, watcherDebug{w}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user