andygrunwald / go-jira

Go client library for Atlassian Jira
https://pkg.go.dev/github.com/andygrunwald/go-jira?tab=doc
MIT License
1.44k stars 458 forks source link

Add support for retrying failed requests #642

Open dcu opened 10 months ago

dcu commented 10 months ago

What would you like to be added?

429 and 5XX errors should be retried

Why is this needed?

it improves the UX otherwise the dev would have to check the response and implement retries every time this library is used

Anything else we need to know?

dcu commented 10 months ago

a way to fix this is using https://github.com/hashicorp/go-retryablehttp like this:

    retryClient := retryablehttp.NewClient()
    retryClient.RetryMax = 15
    standardClient := retryClient.StandardClient()

    tp := jira.BasicAuthTransport{
        Username:  username,
        APIToken:  password,
        Transport: standardClient.Transport,
    }