Skip to content

Conversation

harshil-goel
Copy link
Contributor

No description provided.

@harshil-goel harshil-goel requested a review from a team as a code owner April 16, 2025 12:28

// IsRetryable determines if an error is retryable. Replace this with your own logic.
func IsRetryable(err error) bool {
return strings.Contains(err.Error(), "504 (Gateway Timeout)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Golang errors.Is and and errors.As are the preferred way to compare errors. Comparing error strings is very error prone. When using GRPC we can use its helper functions, so to achieve the same result we can do the following:

import (
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

func IsRetryable(err error) bool {
	return status.Code(err) == codes.Unavailable
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants