Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
service-registry
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
service-registry
Commits
ed600923
Commit
ed600923
authored
Feb 27, 2024
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
107cf690
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
12 deletions
+57
-12
apigateway.go
query/apigateway.go
+9
-1
backend.go
query/backend.go
+9
-1
nm.go
query/nm.go
+12
-1
schedule.go
query/schedule.go
+10
-1
worker.go
query/worker.go
+17
-8
No files found.
query/apigateway.go
View file @
ed600923
...
@@ -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
}
}
...
...
query/backend.go
View file @
ed600923
...
@@ -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
}
}
...
...
query/nm.go
View file @
ed600923
...
@@ -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
}
}
...
...
query/schedule.go
View file @
ed600923
...
@@ -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
}
}
...
...
query/worker.go
View file @
ed600923
...
@@ -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
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment