Commit ca7c9a73 authored by luxq's avatar luxq

update status

parent da2187b2
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/odysseus/service-registry/registry" "github.com/odysseus/service-registry/registry"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"sort" "sort"
"time"
) )
type baseService struct { type baseService struct {
...@@ -62,6 +63,13 @@ func parseInfo(stype common.ServiceType, res *redis.MapStringStringCmd) ServiceI ...@@ -62,6 +63,13 @@ func parseInfo(stype common.ServiceType, res *redis.MapStringStringCmd) ServiceI
if err := res.Scan(&regInfo); err != nil { if err := res.Scan(&regInfo); err != nil {
return nil return nil
} }
if time.Now().UnixMilli()-regInfo.Timestamp > 1000*60*1 {
regInfo.Status = "unhealthy"
}
if time.Now().UnixMilli()-regInfo.Timestamp > 1000*60*10 {
regInfo.Status = "disconnected"
}
return regInfo return regInfo
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment