Commit 89640375 authored by luxq's avatar luxq

update query

parent 5d6df477
......@@ -42,6 +42,8 @@ func (s *ServiceQuerier) Select(service common.ServiceType) ServiceQuery {
return s.backendInfoQuery
case common.SERVICE_API_GATEWAY:
return s.gatewayQuery
case common.SERVICE_WORKER:
return s.workerQuery
default:
return nil
}
......
package query
import (
"github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/registry"
"github.com/stretchr/testify/assert"
"testing"
)
func TestQuery(t *testing.T) {
q := NewQuery(registry.RedisConnParam{
Addr: "localhost:6379",
Password: "",
DbIndex: 0,
})
nmlistInfo, err := q.Select(common.SERVICE_NODE_MANAGER).List()
assert.Equal(t, err, nil)
gatewayInfo, err := q.Select(common.SERVICE_API_GATEWAY).ServiceInfo("gateway1")
assert.Equal(t, err, nil)
t.Logf("nmlistInfo: %v, gatewayInfo: %v", nmlistInfo, gatewayInfo)
}
......@@ -6,8 +6,12 @@ import (
)
type WorkerInfo struct {
Timestamp int64 `redis:"timestamp" json:"timestamp"`
Endpoint string `redis:"endpoint" json:"endpoint"`
Timestamp int64 `json:"timestamp"`
ActiveNM []string `json:"active_nm"`
MinerAddress string `json:"miner_address"`
BenefitAddress string `json:"benefit_address"`
IPs []string `json:"ip_list"`
Status string `json:"status"`
}
func (g WorkerInfo) TimeStamp() int64 {
......
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