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
0eef7ca9
Commit
0eef7ca9
authored
May 11, 2024
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update worker info
parent
19330834
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
4 deletions
+41
-4
baseservice.go
query/baseservice.go
+13
-0
interface.go
query/interface.go
+1
-0
query_test.go
query/query_test.go
+17
-4
worker.go
query/worker.go
+10
-0
No files found.
query/baseservice.go
View file @
0eef7ca9
...
@@ -32,6 +32,11 @@ func (g baseService) List() ([]string, error) {
...
@@ -32,6 +32,11 @@ func (g baseService) List() ([]string, error) {
return
res
,
nil
return
res
,
nil
}
}
func
(
g
baseService
)
Count
()
int
{
count
,
_
:=
getCount
(
g
.
rdb
,
g
.
service
)
return
count
}
func
(
g
baseService
)
ListByPage
(
pageSize
int
,
pageNum
int
)
([]
string
,
int
,
error
)
{
func
(
g
baseService
)
ListByPage
(
pageSize
int
,
pageNum
int
)
([]
string
,
int
,
error
)
{
all
,
err
:=
getAll
(
g
.
rdb
,
g
.
service
)
all
,
err
:=
getAll
(
g
.
rdb
,
g
.
service
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -73,6 +78,14 @@ func parseInfo(stype common.ServiceType, res *redis.MapStringStringCmd) ServiceI
...
@@ -73,6 +78,14 @@ func parseInfo(stype common.ServiceType, res *redis.MapStringStringCmd) ServiceI
return
regInfo
return
regInfo
}
}
func
getCount
(
rdb
*
redis
.
Client
,
serviceType
common
.
ServiceType
)
(
int
,
error
)
{
keys
,
err
:=
rdb
.
Keys
(
context
.
Background
(),
common
.
GetServiceKeyPrefix
(
serviceType
)
+
"*"
)
.
Result
()
if
err
!=
nil
{
return
0
,
err
}
return
len
(
keys
),
nil
}
func
getAll
(
rdb
*
redis
.
Client
,
serviceType
common
.
ServiceType
)
(
ServiceInfoList
,
error
)
{
func
getAll
(
rdb
*
redis
.
Client
,
serviceType
common
.
ServiceType
)
(
ServiceInfoList
,
error
)
{
keys
,
err
:=
rdb
.
Keys
(
context
.
Background
(),
common
.
GetServiceKeyPrefix
(
serviceType
)
+
"*"
)
.
Result
()
keys
,
err
:=
rdb
.
Keys
(
context
.
Background
(),
common
.
GetServiceKeyPrefix
(
serviceType
)
+
"*"
)
.
Result
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
query/interface.go
View file @
0eef7ca9
...
@@ -7,6 +7,7 @@ type ServiceQuery interface {
...
@@ -7,6 +7,7 @@ type ServiceQuery interface {
List
()
([]
string
,
error
)
List
()
([]
string
,
error
)
ListByPage
(
pageSize
int
,
pageNum
int
)
([]
string
,
int
,
error
)
ListByPage
(
pageSize
int
,
pageNum
int
)
([]
string
,
int
,
error
)
ServiceInfo
(
instance
string
)
(
string
,
error
)
ServiceInfo
(
instance
string
)
(
string
,
error
)
Count
()
int
}
}
type
ServiceInfo
interface
{
type
ServiceInfo
interface
{
...
...
query/query_test.go
View file @
0eef7ca9
...
@@ -9,13 +9,26 @@ import (
...
@@ -9,13 +9,26 @@ import (
func
TestQuery
(
t
*
testing
.
T
)
{
func
TestQuery
(
t
*
testing
.
T
)
{
q
:=
NewQuery
(
registry
.
RedisConnParam
{
q
:=
NewQuery
(
registry
.
RedisConnParam
{
Addr
:
"
localhost
:6379"
,
Addr
:
"
43.198.252.255
:6379"
,
Password
:
""
,
Password
:
"
iH0g2CqzjI6SfercGwsT
"
,
DbIndex
:
0
,
DbIndex
:
0
,
})
})
workerPage
,
_
,
err
:=
q
.
Select
(
common
.
SERVICE_WORKER
)
.
ListByPage
(
1
,
2
)
_
=
workerPage
nmlistInfo
,
err
:=
q
.
Select
(
common
.
SERVICE_NODE_MANAGER
)
.
List
()
nmlistInfo
,
err
:=
q
.
Select
(
common
.
SERVICE_NODE_MANAGER
)
.
List
()
_
=
nmlistInfo
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
err
,
nil
)
gatewayInfo
,
err
:=
q
.
Select
(
common
.
SERVICE_API_GATEWAY
)
.
ServiceInfo
(
"gateway1"
)
gatewayListInfo
,
err
:=
q
.
Select
(
common
.
SERVICE_API_GATEWAY
)
.
List
()
_
=
gatewayListInfo
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
err
,
nil
)
t
.
Logf
(
"nmlistInfo: %v, gatewayInfo: %v"
,
nmlistInfo
,
gatewayInfo
)
sclistInfo
,
err
:=
q
.
Select
(
common
.
SERVICE_SCHEDULER
)
.
List
()
_
=
sclistInfo
assert
.
Equal
(
t
,
err
,
nil
)
workerListInfo
,
err
:=
q
.
Select
(
common
.
SERVICE_WORKER
)
.
List
()
_
=
workerListInfo
assert
.
Equal
(
t
,
err
,
nil
)
backendInfo
,
err
:=
q
.
Select
(
common
.
SERVICE_BACKEND
)
.
List
()
_
=
backendInfo
assert
.
Equal
(
t
,
err
,
nil
)
//t.Logf("nmlistInfo: %v, gatewayInfo: %v, sclistInfo: %v, workerListInfo: %v, backendInfo: %v", nmlistInfo, gatewayInfo, sclistInfo, workerListInfo, backendInfo)
}
}
query/worker.go
View file @
0eef7ca9
...
@@ -15,6 +15,16 @@ type WorkerInfo struct {
...
@@ -15,6 +15,16 @@ type WorkerInfo struct {
IP
string
`redis:"ip" json:"ip"`
IP
string
`redis:"ip" json:"ip"`
Nonce
int64
`redis:"nonce" json:"nonce"`
Nonce
int64
`redis:"nonce" json:"nonce"`
TaskList
[]
string
`redis:"task_list" json:"task_list"`
TaskList
[]
string
`redis:"task_list" json:"task_list"`
CpuModel
string
`redis:"cpu_model" json:"cpu_model"`
CpuCore
int
`redis:"cpu_core" json:"cpu_core"`
GPUModel
string
`redis:"gpu_model" json:"gpu_model" json:"gpu_model"`
GPURam
int
`redis:"gpu_ram" json:"gpu_ram"`
RamTotal
int64
`redis:"ram_total" json:"ram_total"`
RamUsed
int64
`redis:"ram_used" json:"ram_used"`
CreateTime
int64
`redis:"create_time" json:"create_time"`
BootupTime
int64
`redis:"bootup_time" json:"bootup_time"`
Workload
int
`redis:"workload" json:"workload"`
MacAddress
string
`redis:"mac_address" json:"mac_address"`
}
}
type
workerQuery
struct
{
type
workerQuery
struct
{
...
...
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