Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNilHTTPClient = errors.New("http client is nil") ErrInvalidMaxReqCount = errors.New("maximum request count is not valid") ErrInvalidBackoff = errors.New("backoff is not valid") ErrNilResHandler = errors.New("response handler is nil") ErrNilRes = errors.New("response is nil") ErrUnsuccessfulStatusCode = errors.New("unsuccessful status code") )
errors
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents retryable http client.
type Option ¶
Option configures client options.
func WithBackoff ¶
WithBackoff configures client's backoff duration, which represents sleeping intervals between retries. Default backoff is 0.
func WithHTTPClient ¶
WithHTTPClient configures client's http client. Default http client is http.DefaultClient{}.
func WithMaxReqCount ¶
WithMaxReqCount configures client's max request count. Default maximum request count is 1.
func WithResHandler ¶
WithResHandler configures client's response handler function which handles http response. Default response handler:
func defaultResHandler(res *http.Response) error { if res == nil { return ErrNilRes } statusCode := res.StatusCode if statusCode < 200 || statusCode > 299 { return ErrStatusCode(statusCode) } return nil }
Click to show internal directories.
Click to hide internal directories.