Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Apr 16, 2025

No description provided.

@ghost ghost self-requested a review 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
}

@mangalaman93 mangalaman93 deleted the harshil-goel/add-retry branch October 1, 2025 05:15
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.

3 participants