Add ability to set max retries to API

This commit is contained in:
Jeff Mitchell 2017-03-01 12:23:54 -05:00
parent d93dcd8a10
commit 2ac644d983

View File

@ -260,9 +260,9 @@ func NewClient(c *Config) (*Client, error) {
// but in e.g. http_test actual redirect handling is necessary // but in e.g. http_test actual redirect handling is necessary
c.HttpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error { c.HttpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
// Returning this value causes the Go net library to not close the // 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 // 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 return http.ErrUseLastResponse
} }
} }
@ -298,6 +298,11 @@ func (c *Client) Address() string {
return c.addr.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 // SetWrappingLookupFunc sets a lookup function that returns desired wrap TTLs
// for a given operation and path // for a given operation and path
func (c *Client) SetWrappingLookupFunc(lookupFunc WrappingLookupFunc) { func (c *Client) SetWrappingLookupFunc(lookupFunc WrappingLookupFunc) {