1
0
Fork 0

Upgrade go-marathon to dd6cbd4.

Fixes a problem with UnreachableStrategy being available now in two
type-incompatible formats (object and string).

We also upgrade the transitive dependency
github.com/donovanhide/eventsource.
This commit is contained in:
Timo Reimann 2017-05-19 14:24:28 +02:00 committed by Ludovic Fernandez
parent 7a34303593
commit 9fbe21c534
9 changed files with 206 additions and 48 deletions

View file

@ -150,8 +150,6 @@ type Marathon interface {
}
var (
// ErrInvalidResponse is thrown when marathon responds with invalid or error response
ErrInvalidResponse = errors.New("invalid response from Marathon")
// ErrMarathonDown is thrown when all the marathon endpoints are down
ErrMarathonDown = errors.New("all the Marathon hosts are presently down")
// ErrTimeoutError is thrown when the operation has timed out
@ -190,6 +188,11 @@ type httpClient struct {
config Config
}
// newRequestError signals that creating a new http.Request failed
type newRequestError struct {
error
}
// NewClient creates a new marathon client
// config: the configuration to use
func NewClient(config Config) (Marathon, error) {
@ -298,8 +301,7 @@ func (r *marathonClient) apiCall(method, path string, body, result interface{})
if response.StatusCode >= 200 && response.StatusCode <= 299 {
if result != nil {
if err := json.Unmarshal(respBody, result); err != nil {
r.debugLog.Printf("apiCall(): failed to unmarshall the response from marathon, error: %s\n", err)
return ErrInvalidResponse
return fmt.Errorf("failed to unmarshal response from Marathon: %s", err)
}
}
return nil
@ -317,7 +319,8 @@ func (r *marathonClient) apiCall(method, path string, body, result interface{})
}
}
// buildAPIRequest creates a default API request
// buildAPIRequest creates a default API request.
// It fails when there is no available member in the cluster anymore or when the request can not be built.
func (r *marathonClient) buildAPIRequest(method, path string, reader io.Reader) (request *http.Request, member string, err error) {
// Grab a member from the cluster
member, err = r.hosts.getMember()
@ -328,7 +331,7 @@ func (r *marathonClient) buildAPIRequest(method, path string, reader io.Reader)
// Build the HTTP request to Marathon
request, err = r.client.buildMarathonRequest(method, member, path, reader)
if err != nil {
return nil, member, err
return nil, member, newRequestError{err}
}
return request, member, nil
}