From 5ef2b0145b3d439258461d25c65ec68bf35dff50 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 1 Mar 2017 12:23:54 -0500 Subject: [PATCH] Add ability to set max retries to API --- api/client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/client.go b/api/client.go index f35225a94..f23e1009d 100644 --- a/api/client.go +++ b/api/client.go @@ -260,9 +260,9 @@ func NewClient(c *Config) (*Client, error) { // but in e.g. http_test actual redirect handling is necessary c.HttpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error { // Returning this value causes the Go net library to not close the - // response body and nil out the error. Otherwise pester tries + // response body and to nil out the error. Otherwise pester tries // three times on every redirect because it sees an error from this - // function being passed through. + // function (to prevent redirects) passing through to it. return http.ErrUseLastResponse } } @@ -298,6 +298,11 @@ func (c *Client) Address() string { return c.addr.String() } +// SetMaxRetries sets the number of retries that will be used in the case of certain errors +func (c *Client) SetMaxRetries(retries int) { + c.config.MaxRetries = retries +} + // SetWrappingLookupFunc sets a lookup function that returns desired wrap TTLs // for a given operation and path func (c *Client) SetWrappingLookupFunc(lookupFunc WrappingLookupFunc) {