hcloud-go
hcloud-go copied to clipboard
Retry transient HTTP Errors
Please (re)implement retries for transient HTTP error codes (502, 503, 504, etc) with sensible defaults
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.
Hey @mschfh,
plainly retrying requests could be a bit dangerous, as we do not have an idempotent API. Actions might be taken twice, if the actual API request arrived at the backend, but then some proxy in the middle fails the request.
Do you know of any SDKs/API Clients which do this?
afaik aws's SDK does this
https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.
unstale
Until we find out the best approach to solve this, you may use an external library that implement a retry round tripper:
package main
import (
"net/http"
"github.com/hashicorp/go-retryablehttp"
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)
func main() {
token := "YOUR_API_TOKEN"
httpClient := &http.Client{}
httpClient.Transport = &retryablehttp.RoundTripper{}
hcloud.NewClient(
hcloud.WithToken(token),
hcloud.WithHTTPClient(httpClient),
)
}