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
de555667
Commit
de555667
authored
Jan 16, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add post task result
parent
83831395
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
169 additions
and
1 deletion
+169
-1
go.mod
go.mod
+3
-1
go.sum
go.sum
+137
-0
workerManager.go
server/workerManager.go
+16
-0
post.go
utils/post.go
+13
-0
No files found.
go.mod
View file @
de555667
...
@@ -4,6 +4,7 @@ go 1.18
...
@@ -4,6 +4,7 @@ go 1.18
require (
require (
github.com/BurntSushi/toml v1.3.2
github.com/BurntSushi/toml v1.3.2
github.com/astaxie/beego v1.12.3
github.com/ethereum/go-ethereum v1.13.10
github.com/ethereum/go-ethereum v1.13.10
github.com/hashicorp/golang-lru v0.5.4
github.com/hashicorp/golang-lru v0.5.4
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
...
@@ -14,6 +15,7 @@ require (
...
@@ -14,6 +15,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/spf13/viper v1.18.2
golang.org/x/crypto v0.17.0
google.golang.org/grpc v1.60.1
google.golang.org/grpc v1.60.1
)
)
...
@@ -48,7 +50,6 @@ require (
...
@@ -48,7 +50,6 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.15.0 // indirect
...
@@ -56,6 +57,7 @@ require (
...
@@ -56,6 +57,7 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
)
...
...
go.sum
View file @
de555667
This diff is collapsed.
Click to expand it.
server/workerManager.go
View file @
de555667
...
@@ -3,6 +3,7 @@ package server
...
@@ -3,6 +3,7 @@ package server
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"github.com/golang/protobuf/proto"
lru
"github.com/hashicorp/golang-lru"
lru
"github.com/hashicorp/golang-lru"
"github.com/odysseus/nodemanager/utils"
"github.com/odysseus/nodemanager/utils"
odysseus
"github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1"
odysseus
"github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1"
...
@@ -263,6 +264,21 @@ func (wm *WorkerManager) manageWorker(worker *Worker) error {
...
@@ -263,6 +264,21 @@ func (wm *WorkerManager) manageWorker(worker *Worker) error {
// remove task from cache.
// remove task from cache.
worker
.
recentTask
.
Remove
(
result
.
TaskId
)
worker
.
recentTask
.
Remove
(
result
.
TaskId
)
}
}
taskResponse
:=
&
odysseus
.
TaskResponse
{
TaskId
:
task
.
TaskId
,
TaskResult
:
result
.
TaskResult
,
TaskUid
:
task
.
TaskUid
,
TaskFee
:
task
.
TaskFee
,
}
d
,
_
:=
proto
.
Marshal
(
taskResponse
)
go
func
()
{
err
:=
utils
.
Post
(
task
.
TaskCallback
,
d
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"post task result failed"
)
}
else
{
log
.
WithField
(
"taskid"
,
task
.
TaskId
)
.
Debug
(
"post task result"
)
}
}()
_
=
wm
.
AddWorker
(
worker
)
_
=
wm
.
AddWorker
(
worker
)
// todo: post event for task succeed or failed
// todo: post event for task succeed or failed
return
true
return
true
...
...
utils/post.go
0 → 100644
View file @
de555667
package
utils
import
(
"github.com/astaxie/beego/httplib"
)
func
Post
(
url
string
,
data
[]
byte
)
error
{
_
,
err
:=
httplib
.
Post
(
url
)
.
Body
(
data
)
.
Response
()
if
err
!=
nil
{
return
err
}
return
nil
}
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