Commit ed600923 authored by luxq's avatar luxq

update code

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