-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(torch): v1 resources added #2
Conversation
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
… in the db Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you still want to use context.TODO() - please give a very comprehensive reasoning why instead of other type of contexts 🙏
Great job so far!
pkg/nodes/queue.go
Outdated
func ProcessTaskQueue() { | ||
ticker := time.NewTicker(5 * time.Second) // Set the interval to 5 seconds | ||
//defer ticker.Stop() // Stop the ticker when the function exits | ||
|
||
for { | ||
select { | ||
case <-ticker.C: | ||
processQueue() | ||
} | ||
} | ||
} | ||
|
||
// processQueue process the nodes in the queue and tries to generate the Multi Address | ||
func processQueue() { | ||
red := redis.InitRedisConfig() | ||
ctx := context.TODO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a good practice you need to pass context downstream so you can have a select case if the context is either done or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated these functions, now they look like:
// ProcessTaskQueue processes the pending tasks in the queue the time specified in the const TickerTime.
func ProcessTaskQueue(ctx context.Context) {
ticker := time.NewTicker(TickerTime)
for {
select {
case <-ctx.Done():
// The context has been canceled, exit the loop.
return
case <-ticker.C:
processQueue(ctx)
}
}
}
// processQueue process the nodes in the queue and tries to generate the Multi Address
func processQueue(ctx context.Context) {
red := redis.InitRedisConfig()
for {
select {
case <-ctx.Done():
// The context has been canceled, exit the loop.
return
case peer := <-taskQueue:
// Perform the operation with the node
err := CheckNodesInDBOrCreateThem(peer, red, ctx)
if err != nil {
log.Error("Error checking the nodes: CheckNodesInDBOrCreateThem - ", err)
}
}
}
}
is this the right usage as you mentioned?
Co-authored-by: Nguyen Nhu Viet <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
…t from k8s Signed-off-by: Jose Ramon Mañes <[email protected]>
…therwise it will generate it Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🖖 another round please 🙏
} | ||
|
||
// processQueue process the nodes in the queue and tries to generate the Multi Address | ||
func processQueue() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I highly recommend you return errors up the call stack as the never ending loop of calls based on ticker and no exit is bad design pick
for { | ||
select { | ||
case <-ticker.C: | ||
processQueue() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally here you need to process errors returned from processQueue()
Also, you need to return a general error or nil error in ProcessTaskQueue() func as it is a good practice
pkg/nodes/queue.go
Outdated
var ( | ||
taskQueue = make(chan config.Peer) // taskQueue channel for pending tasks (peers to process later). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not good to do taskQueue like this.
You can either create a struct that holds the queue functions or only create it in AddPhase
log.Info("MultiAddr for node ", peer.NodeName, " is: [", output, "]") | ||
|
||
log.Info("Adding node to the queue: [", peer.NodeName, "]") | ||
go AddToQueue(peer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not good that we are not doing error handling here
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
Signed-off-by: Jose Ramon Mañes <[email protected]>
we will review the pending points here: |
Overview
Checklist