You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
client:=client.New(accID, licenseKey)
backoff.Retry(func() error {
resp, err:=client.Download(ctx, edition, hash)
iferr!=nil {
// is this an error that won't be fixed by a retry?if (strings.Contains(err.Error(), "AUTHORIZATION_INVALID") ||strings.Contains(err.Error(), "LICENSE_KEY_INVALID")) {
returnbackoff.Permanent(err)
}
// retryreturnerr
}
// <rest omitted for brevity>
}, backoff.BackOff(...))
I don't love relying on the Error() containing certain strings to decide if I should retry or not.
export the underlying github.com/maxmind/geoipupdate/v7/internal/HTTPError so I can use that with errors.As; a type alias in the package client should do it type HTTPError = internal.HTTPError
export the internal.IsPermanentError func
The text was updated successfully, but these errors were encountered:
7.1.0
* Allow the `Host` configuration directive and the `GEOIPUPDATE_HOST`
environment variable to accept a value with the scheme set. If not set, it
will continue to default to `https://`. Pull request by Gabe Cook. GitHub
#310.
* Export `HTTPError` to enable fine-grained error handling for users of
`github.com/maxmind/geoipupdate/client`. Pull request by Ryan Davis. GitHub
#341.
I'm using the golang client https://pkg.go.dev/github.com/maxmind/geoipupdate/[email protected]/client#Client.Download, and would like a better way to differentiate between permanent errors and transient errors.
Right now my code looks something like:
I don't love relying on the
Error()
containing certain strings to decide if I should retry or not.Would you consider providing some mechanism for inspecting the error so I could retry as needed based on https://dev.maxmind.com/geoip/docs/web-services/responses/#errors?
Some implementation ideas:
github.com/maxmind/geoipupdate/v7/internal/HTTPError
so I can use that witherrors.As
; a type alias in thepackage client
should do ittype HTTPError = internal.HTTPError
internal.IsPermanentError
funcThe text was updated successfully, but these errors were encountered: