Retry temporary errors by default (#107)

* Adding Aurora URL validator in order to handle scenarios where incomplete information is passed to the client. The client will do its best to guess the missing information such as protocol and port.

* Upgraded to testify 1.3.0.

* Added configuration to fail on a non-temporary error. This is reverting to the original behavior of the retry mechanism. However, this allows the user to opt to fail in a non-temporary error.
This commit is contained in:
Renan DelValle 2019-06-11 11:47:14 -07:00 committed by GitHub
parent 4ffb509939
commit 6dc4bf93b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 2795 additions and 1009 deletions

13
util.go
View file

@ -8,6 +8,8 @@ import (
"github.com/pkg/errors"
)
const apiPath = "/api"
var ActiveStates = make(map[aurora.ScheduleStatus]bool)
var SlaveAssignedStates = make(map[aurora.ScheduleStatus]bool)
var LiveStates = make(map[aurora.ScheduleStatus]bool)
@ -40,14 +42,14 @@ func init() {
}
}
func validateAndPopulateAuroraURL(urlStr string) (string, error) {
func validateAuroraURL(location string) (string, error) {
// If no protocol defined, assume http
if !strings.Contains(urlStr, "://") {
urlStr = "http://" + urlStr
if !strings.Contains(location, "://") {
location = "http://" + location
}
u, err := url.Parse(urlStr)
u, err := url.Parse(location)
if err != nil {
return "", errors.Wrap(err, "error parsing url")
@ -67,7 +69,8 @@ func validateAndPopulateAuroraURL(urlStr string) (string, error) {
return "", errors.Errorf("only protocols http and https are supported %v\n", u.Scheme)
}
if u.Path != "/api" {
// This could theoretically be elsewhwere but we'll be strict for the sake of simplicty
if u.Path != apiPath {
return "", errors.Errorf("expected /api path %v\n", u.Path)
}