Created
March 6, 2022 12:16
-
-
Save MaikelVeen/fce475525704dee426b0f25a050b33fe to your computer and use it in GitHub Desktop.
Using the Retry pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count int | |
func GetPdfUrl(ctx context.Context) (string, error) { | |
count++ | |
if count <= 3 { | |
return "", errors.New("boom") | |
} else { | |
return "https://linktopdf.com", nil | |
} | |
} | |
func main() { | |
r := Retry(GetPdfUrl, 5, 2*time.Second) | |
res, err := r(context.Background()) | |
fmt.Println(res, err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gist