GoDoxy/internal/watcher/health/monitor/last_seen.go
2025-01-03 16:56:18 +08:00

22 lines
424 B
Go

package monitor
import (
"time"
F "github.com/yusing/go-proxy/internal/utils/functional"
)
var lastSeenMap = F.NewMapOf[string, time.Time]()
func SetLastSeen(service string, lastSeen time.Time) {
lastSeenMap.Store(service, lastSeen)
}
func UpdateLastSeen(service string) {
SetLastSeen(service, time.Now())
}
func GetLastSeen(service string) time.Time {
lastSeen, _ := lastSeenMap.Load(service)
return lastSeen
}