Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scheduler
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
scheduler
Commits
cd9b85b1
Commit
cd9b85b1
authored
Jan 29, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
115c39f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
node.go
server/node.go
+1
-1
kafka.go
utils/kafka.go
+6
-7
kafka_test.go
utils/kafka_test.go
+2
-0
No files found.
server/node.go
View file @
cd9b85b1
...
...
@@ -83,7 +83,7 @@ func (n *Node) Loop(idx int) {
postReceipt
:=
func
(
task
*
odysseus
.
TaskContent
,
result
*
odysseus
.
TaskResponse
,
err
error
)
error
{
receipt
:=
new
(
odysseus
.
TaskReceipt
)
receipt
.
TaskUuid
=
task
.
TaskUuid
receipt
.
TaskFinishTime
=
uint64
(
time
.
Now
()
.
Unix
())
receipt
.
TaskFinishTime
=
uint64
(
time
.
Now
()
.
Unix
Nano
())
receipt
.
TaskId
=
task
.
TaskId
receipt
.
TaskUid
=
task
.
TaskUid
receipt
.
TaskWorkload
=
task
.
TaskWorkload
...
...
utils/kafka.go
View file @
cd9b85b1
package
utils
import
(
"fmt"
"github.com/IBM/sarama"
"github.com/gogo/protobuf/proto"
odysseus
"github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1"
"time
"
log
"github.com/sirupsen/logrus
"
)
// NewKafkaProducer Create a new KafkaProducer.
func
NewKafkaProducer
(
brokers
[]
string
)
(
sarama
.
AsyncProducer
,
error
)
{
kafkaConfig
:=
sarama
.
NewConfig
()
kafkaConfig
.
Producer
.
RequiredAcks
=
sarama
.
WaitForLocal
// Only wait for the leader to ack
kafkaConfig
.
Producer
.
Compression
=
sarama
.
CompressionSnappy
// Compress messages
kafkaConfig
.
Producer
.
Flush
.
Frequency
=
500
*
time
.
Millisecond
// Flush batches every 500ms
kafkaConfig
.
Net
.
ResolveCanonicalBootstrapServers
=
false
//
kafkaConfig.Producer.RequiredAcks = sarama.WaitForLocal // Only wait for the leader to ack
//
kafkaConfig.Producer.Compression = sarama.CompressionSnappy // Compress messages
//
kafkaConfig.Producer.Flush.Frequency = 500 * time.Millisecond // Flush batches every 500ms
//
kafkaConfig.Net.ResolveCanonicalBootstrapServers = false
producer
,
err
:=
sarama
.
NewAsyncProducer
(
brokers
,
kafkaConfig
)
...
...
@@ -24,7 +23,7 @@ func NewKafkaProducer(brokers []string) (sarama.AsyncProducer, error) {
go
func
()
{
for
ierr
:=
range
producer
.
Errors
()
{
fmt
.
Printf
(
"Failed to send log entry to kafka: %v
\n
"
,
ierr
)
log
.
WithError
(
ierr
)
.
Debug
(
"Failed to send log entry to kafka"
)
}
}()
...
...
utils/kafka_test.go
View file @
cd9b85b1
package
utils
import
(
"fmt"
"github.com/google/uuid"
basev1
"github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1"
"strings"
...
...
@@ -24,6 +25,7 @@ func Test(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"FireTaskReceipt failed with err:%s"
,
err
.
Error
())
}
fmt
.
Println
(
"send task receipt success"
)
time
.
Sleep
(
time
.
Second
)
}
...
...
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