Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodemanager
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
nodemanager
Commits
3c0346bc
Commit
3c0346bc
authored
Jan 16, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update worker status
parent
4a779d72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
workerstatu.go
server/workerstatu.go
+10
-5
No files found.
server/workerstatu.go
View file @
3c0346bc
...
@@ -3,11 +3,10 @@ package server
...
@@ -3,11 +3,10 @@ package server
import
(
import
(
"context"
"context"
"github.com/odysseus/nodemanager/config"
"github.com/odysseus/nodemanager/config"
odysseus
"github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1"
"strconv"
"strconv"
)
)
func
(
wm
*
WorkerManager
)
AddWorker
(
worker
*
Worker
)
{
func
(
wm
*
WorkerManager
)
AddWorker
(
worker
*
Worker
)
error
{
for
_
,
device
:=
range
worker
.
deviceInfo
{
for
_
,
device
:=
range
worker
.
deviceInfo
{
// add device to redis
// add device to redis
priority
:=
0
priority
:=
0
...
@@ -17,13 +16,19 @@ func (wm *WorkerManager) AddWorker(worker *Worker) {
...
@@ -17,13 +16,19 @@ func (wm *WorkerManager) AddWorker(worker *Worker) {
}
}
}
}
// add worker to redis queue
// add worker to redis queue
wm
.
rdb
.
Set
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
strconv
.
FormatInt
(
worker
.
uuid
,
10
),
odysseus
.
WorkerStatus_WorkerStatusActive
,
0
)
if
err
:=
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
strconv
.
FormatInt
(
worker
.
uuid
,
10
),
config
.
GetConfig
()
.
Endpoint
)
.
Err
();
err
!=
nil
{
return
err
}
//wm.rdb.Set(context.Background(), config.WORKER_STATUS_PREFIX+strconv.FormatInt(worker.uuid, 10), odysseus.WorkerStatus_WorkerStatusActive, 0)
return
nil
}
}
func
(
wm
*
WorkerManager
)
ActiveWorker
(
worker
*
Worker
)
{
func
(
wm
*
WorkerManager
)
ActiveWorker
(
worker
*
Worker
)
{
wm
.
rdb
.
Set
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
strconv
.
FormatInt
(
worker
.
uuid
,
10
),
odysseus
.
WorkerStatus_WorkerStatusActive
,
0
)
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
strconv
.
FormatInt
(
worker
.
uuid
,
10
),
config
.
GetConfig
()
.
Endpoint
)
//wm.rdb.Set(context.Background(), config.WORKER_STATUS_PREFIX+strconv.FormatInt(worker.uuid, 10), odysseus.WorkerStatus_WorkerStatusActive, 0)
}
}
func
(
wm
*
WorkerManager
)
InActiveWorker
(
worker
*
Worker
)
{
func
(
wm
*
WorkerManager
)
InActiveWorker
(
worker
*
Worker
)
{
wm
.
rdb
.
Set
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
strconv
.
FormatInt
(
worker
.
uuid
,
10
),
odysseus
.
WorkerStatus_WorkerStatusInActive
,
0
)
wm
.
rdb
.
SRem
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
strconv
.
FormatInt
(
worker
.
uuid
,
10
),
config
.
GetConfig
()
.
Endpoint
)
//wm.rdb.Set(context.Background(), config.WORKER_STATUS_PREFIX+strconv.FormatInt(worker.uuid, 10), odysseus.WorkerStatus_WorkerStatusInActive, 0)
}
}
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