-
Notifications
You must be signed in to change notification settings - Fork 112
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
refactor: retry logic for deployment key #223
refactor: retry logic for deployment key #223
Conversation
services/monkey/helpers.go
Outdated
@@ -39,3 +43,79 @@ func (m *Monkey) storeLogs(r io.ReadSeeker) (string, error) { | |||
|
|||
return cid, nil | |||
} | |||
|
|||
// Retry function with a custom condition | |||
func Retry(maxRetries int, waitBeforeRetry time.Duration, operation interface{}, condition interface{}, args ...interface{}) ([]interface{}, error) { |
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.
tests are passing. however, i'm no sure using interface{} (should be any
btw) is a good choice here.
make a retry just for our use case since it's used only once.
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.
Thanks for your comment. I have reverted and moved the retry logic to helpers.
I just needed one advise on how to get the global variable for maxRetries and waitBeforeRetry?
Closes #152
Sometimes, a build might be triggered before the repository is registered, which mean a deployment key was added. For these reason we have a retry logic here https://github.com/taubyte/tau/services/monkey/job.go#L88. Frankly, this code does not look good.
I suggest moving the check for deployment key to https://github.com/taubyte/tau/services/monkey/job.go#L41, and use a helper function that will retry for a number of times till we get repo with a deployment key.
Add a reusable Retry helper function.