Commit ed600923 authored by luxq's avatar luxq

update code

parent 107cf690
...@@ -3,6 +3,7 @@ package query ...@@ -3,6 +3,7 @@ package query
import ( import (
"encoding/json" "encoding/json"
"github.com/odysseus/service-registry/common" "github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/registry"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
...@@ -22,9 +23,16 @@ func (g GatewayInfo) Message() json.RawMessage { ...@@ -22,9 +23,16 @@ func (g GatewayInfo) Message() json.RawMessage {
func (g GatewayInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo { func (g GatewayInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo {
var info GatewayInfo var info GatewayInfo
if err := res.Scan(&info); err != nil { var regInfo registry.RegistryInfo
if err := res.Scan(&regInfo); err != nil {
return nil return nil
} }
if err := json.Unmarshal([]byte(regInfo.Detail), &info); err != nil {
return nil
}
info.Timestamp = regInfo.Timestamp
info.Endpoint = regInfo.Endpoint
return info return info
} }
......
...@@ -3,6 +3,7 @@ package query ...@@ -3,6 +3,7 @@ package query
import ( import (
"encoding/json" "encoding/json"
"github.com/odysseus/service-registry/common" "github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/registry"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
...@@ -22,9 +23,16 @@ func (g BackendInfo) Message() json.RawMessage { ...@@ -22,9 +23,16 @@ func (g BackendInfo) Message() json.RawMessage {
func (g BackendInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo { func (g BackendInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo {
var info BackendInfo var info BackendInfo
if err := res.Scan(&info); err != nil { var regInfo registry.RegistryInfo
if err := res.Scan(&regInfo); err != nil {
return nil return nil
} }
if err := json.Unmarshal([]byte(regInfo.Detail), &info); err != nil {
return nil
}
info.Timestamp = regInfo.Timestamp
info.Endpoint = regInfo.Endpoint
return info return info
} }
......
...@@ -3,12 +3,14 @@ package query ...@@ -3,12 +3,14 @@ package query
import ( import (
"encoding/json" "encoding/json"
"github.com/odysseus/service-registry/common" "github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/registry"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
type NodeManagerInfo struct { type NodeManagerInfo struct {
Timestamp int64 `redis:"timestamp" json:"timestamp"` Timestamp int64 `redis:"timestamp" json:"timestamp"`
Endpoint string `redis:"endpoint" json:"endpoint"` Endpoint string `redis:"endpoint" json:"endpoint"`
Status string `redis:"status" json:"status"`
} }
func (g NodeManagerInfo) TimeStamp() int64 { func (g NodeManagerInfo) TimeStamp() int64 {
...@@ -22,9 +24,18 @@ func (g NodeManagerInfo) Message() json.RawMessage { ...@@ -22,9 +24,18 @@ func (g NodeManagerInfo) Message() json.RawMessage {
func (g NodeManagerInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo { func (g NodeManagerInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo {
var info NodeManagerInfo var info NodeManagerInfo
if err := res.Scan(&info); err != nil {
var regInfo registry.RegistryInfo
if err := res.Scan(&regInfo); err != nil {
return nil return nil
} }
if err := json.Unmarshal([]byte(regInfo.Detail), &info); err != nil {
return nil
}
info.Timestamp = regInfo.Timestamp
info.Endpoint = regInfo.Endpoint
return info return info
} }
......
...@@ -3,12 +3,14 @@ package query ...@@ -3,12 +3,14 @@ package query
import ( import (
"encoding/json" "encoding/json"
"github.com/odysseus/service-registry/common" "github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/registry"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
type SchedulerInfo struct { type SchedulerInfo struct {
Timestamp int64 `redis:"timestamp" json:"timestamp"` Timestamp int64 `redis:"timestamp" json:"timestamp"`
Endpoint string `redis:"endpoint" json:"endpoint"` Endpoint string `redis:"endpoint" json:"endpoint"`
Status string `redis:"status" json:"status"`
} }
func (g SchedulerInfo) TimeStamp() int64 { func (g SchedulerInfo) TimeStamp() int64 {
...@@ -22,9 +24,16 @@ func (g SchedulerInfo) Message() json.RawMessage { ...@@ -22,9 +24,16 @@ func (g SchedulerInfo) Message() json.RawMessage {
func (g SchedulerInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo { func (g SchedulerInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo {
var info SchedulerInfo var info SchedulerInfo
if err := res.Scan(&info); err != nil { var regInfo registry.RegistryInfo
if err := res.Scan(&regInfo); err != nil {
return nil return nil
} }
if err := json.Unmarshal([]byte(regInfo.Detail), &info); err != nil {
return nil
}
info.Timestamp = regInfo.Timestamp
info.Endpoint = regInfo.Endpoint
return info return info
} }
......
...@@ -3,17 +3,19 @@ package query ...@@ -3,17 +3,19 @@ package query
import ( import (
"encoding/json" "encoding/json"
"github.com/odysseus/service-registry/common" "github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/registry"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
type WorkerInfo struct { type WorkerInfo struct {
Timestamp int64 `json:"timestamp"` Timestamp int64 `redis:"timestamp" json:"timestamp"`
HearBeat int64 `json:"heartbeat"` Endpoint string `redis:"endpoint" json:"endpoint"`
ActiveNM []string `json:"active_nm"` HearBeat int64 `redis:"heartbeat" json:"heartbeat"`
MinerAddress string `json:"miner_address"` ActiveNM []string `redis:"active_nm" json:"active_nm"`
BenefitAddress string `json:"benefit_address"` MinerAddress string `redis:"miner_address" json:"miner_address"`
IPs []string `json:"ip_list"` BenefitAddress string `redis:"benefit_address" json:"benefit_address"`
Status string `json:"status"` IPs []string `redis:"ip_list" json:"ip_list"`
Status string `redis:"status" json:"status"`
} }
func (g WorkerInfo) TimeStamp() int64 { func (g WorkerInfo) TimeStamp() int64 {
...@@ -27,9 +29,16 @@ func (g WorkerInfo) Message() json.RawMessage { ...@@ -27,9 +29,16 @@ func (g WorkerInfo) Message() json.RawMessage {
func (g WorkerInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo { func (g WorkerInfo) Parse(res *redis.MapStringStringCmd) ServiceInfo {
var info WorkerInfo var info WorkerInfo
if err := res.Scan(&info); err != nil { var regInfo registry.RegistryInfo
if err := res.Scan(&regInfo); err != nil {
return nil return nil
} }
if err := json.Unmarshal([]byte(regInfo.Detail), &info); err != nil {
return nil
}
info.Timestamp = regInfo.Timestamp
info.Endpoint = regInfo.Endpoint
return info return info
} }
......
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