-
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
introduce MarkTemporary #28
Conversation
WalkthroughThe changes introduce enhanced error handling in the retry logic by adding types and methods to mark errors as temporary or permanent. This update includes modifications to the existing Changes
Sequence DiagramsEnhanced Error Handling in
|
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.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- retry.go (2 hunks)
- retry_test.go (1 hunks)
Additional comments not posted (1)
retry_test.go (1)
283-296
: The test forMarkTemporary
is well-implemented to ensure that a temporary error allows the maximum number of retries. It's important to ensure these tests cover all potential edge cases, such as the behavior when the maximum retry count is reached.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
Actionable comments posted: 0
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- func.go (2 hunks)
- func_test.go (1 hunks)
- retry.go (2 hunks)
- retry_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- retry_test.go
Additional comments not posted (5)
func.go (1)
Line range hint
1-25
: The rest of theDoValue
function appears well-structured and correct.Also applies to: 31-46
func_test.go (2)
33-45
: The testTestDoValue_MarkPermanent
correctly checks for non-retry on permanent errors.
47-60
: The testTestDoValue_MarkTemporary
correctly verifies the retry logic for temporary errors.retry.go (2)
107-131
: The implementation of themyError
type and its methods are correctly defined and follow best practices for custom error types in Go.
126-133
: The implementations ofMarkTemporary
andMarkPermanent
are correct and well-documented.
// short cut for calling Unwrap | ||
if err, ok := err.(*myError); ok { | ||
if err.temporary { | ||
continue | ||
} |
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.
Consider refactoring the error handling logic for myError
to avoid duplication and improve maintainability.
+ func handleMyError(err error) (bool, error) {
+ if err, ok := err.(*myError); ok {
+ if err.temporary {
+ return true, nil
+ }
+ return false, err.error
+ }
+ return false, nil
+ }
+
+ // Usage in the code
+ shouldContinue, unwrappedErr := handleMyError(err)
+ if shouldContinue {
+ continue
+ }
+ if unwrappedErr != nil {
+ return zero, unwrappedErr
+ }
Also applies to: 47-50
// short cut for calling Unwrap | ||
if err, ok := err.(*myError); ok { | ||
if err.temporary { | ||
continue | ||
} |
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.
Consider refactoring the error handling logic for myError
in the Do
function to avoid duplication and improve maintainability, similar to the suggestion made in func.go
.
Also applies to: 94-97
Summary by CodeRabbit
New Features
Tests
These updates improve error handling by distinguishing between temporary and permanent errors, enhancing the reliability of retry mechanisms.