Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultBackOff = backoff.ExponentialBackOff{ InitialInterval: 500 * time.Millisecond, RandomizationFactor: 0.5, Multiplier: 1.5, MaxInterval: 5 * time.Second, MaxElapsedTime: 30 * time.Second, Stop: backoff.Stop, Clock: backoff.SystemClock, }
DefaultBackOff is an opinionated backoff.ExponentialBackOff which implements the backoff.BackOff interface.
var DefaultRateLimiter = rate.NewLimiter(rate.Limit(1), 1)
DefaultRateLimiter is an opinionated rate.Limiter which implements the Waiter interface.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client provides all required functionality for 1. performing http requests with a Requester 2. while not exceeding a defined rate limit with a Waiter 3. temporary errors can be retried with a backoff.BackOff
func NewWithDefaults ¶
func NewWithDefaults() *Client
NewWithDefaults returns a client with the two default options for rate limiting and backoff DefaultRateLimiter and DefaultBackOff
type HTTPError ¶
HTTPError exposes the http.Response while also giving some convenience for the http status code & response body.
type Option ¶
type Option func(c *Client)
Option is a function to alter the behaviour of a Client.
func WithBackOff ¶
func WithBackOff(bo backoff.BackOff) Option
WithBackOff configures the Client to use the given backoff.BackOff.
func WithHttpClient ¶
WithHttpClient configures the Client to use the given Requester. http.DefaultClient implements the Requester interface.
func WithRateLimiter ¶
WithRateLimiter configures the Client to use the given Waiter.
type Requester ¶
Requester is this libraries interface for a http.Client. This is due to https://github.com/golang/go/issues/16047