Documentation ¶
Overview ¶
A plugin for retry HTTP requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func When ¶
func When(cond hx.ResponseHandlerCond, bo backoff.BackOff) hx.Option
When creates an option that provides retry mechanism for your http client.
bo := backoff.NewExponentialBackOff() bo.InitialInterval = 50 * time.Millisecond bo.MaxInterval = 500 * time.Millisecond err := hx.Post(ctx, "https://example.com/api/messages", retry.When(hx.Any(hx.IsServerError(), hx.IsTemporaryError()), bo), hx.JSON(&in), hx.WhenSuccess(hx.AsJSON(&out)), hx.WhenFailure(hx.AsError()), )
Types ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
func NewTransport ¶
func NewTransport( parent http.RoundTripper, cond hx.ResponseHandlerCond, bo backoff.BackOff, ) *Transport
Click to show internal directories.
Click to hide internal directories.