package retry
import "github.com/streadway/handy/retry"
Package retry implements a retrying transport based on a combination of strategies.
Index ¶
- Variables
- type Attempt
- type Decision
- type Delayer
- func Constant(delta time.Duration) Delayer
- func Exponential(base time.Duration) Delayer
- func Fibonacci(delta time.Duration) Delayer
- func Linear(delta time.Duration) Delayer
- type MaxError
- type Retryer
- func All(conditions ...Retryer) Retryer
- func EOF() Retryer
- func Errors() Retryer
- func Idempotent() Retryer
- func Max(limit uint) Retryer
- func Method(methods ...string) Retryer
- func Net() Retryer
- func Over(statusCode int) Retryer
- func Temporary() Retryer
- func Timeout(limit time.Duration) Retryer
- type TimeoutError
- type Transport
Variables ¶
Types ¶
type Attempt ¶
Attempt counts the round trips issued, starting from 1. Response is valid only when Err is nil.
type Decision ¶
type Decision int
Decision signals the intent of a Retryer
type Delayer ¶
type Delayer func(Attempt)
Delayer sleeps or selects any amount of time for each attempt.
func Constant ¶
Constant sleeps for delta duration
func Exponential ¶
Linear sleeps for delta * 2^attempts
func Fibonacci ¶
Fibonacci sleeps for delta * fib(attempts)
func Linear ¶
Linear sleeps for delta * the number of attempts
type MaxError ¶
type MaxError struct {
// contains filtered or unexported fields
}
MaxError is returned from RoundTrip when the maximum attempts has been reached.
func (MaxError) Error ¶
type Retryer ¶
Retryer chooses whether or not to retry this request. The error is only valid when the Retyer returns Abort.
func All ¶
All aggregates decisions from Retryers for an attempt. All returns Abort and the error on the first Abort. If at least one returns Retry All returns Retry with nil error. Otherwise All returns Ignore with nil error.
func EOF ¶
func EOF() Retryer
EOF retries only when the error is EOF
func Errors ¶
func Errors() Retryer
Errors returns Retry when the attempt produced an error.
func Idempotent ¶
func Idempotent() Retryer
Idempotent retries when the request is expected to be idempotent according to RFC 2616, section 9.1.2. https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.2
func Max ¶
Max errors after a limited number of attempts
func Method ¶
Method retries when the request method is one of the given methods
func Net ¶
func Net() Retryer
Net retries errors returned by the 'net' package.
func Over ¶
Over retries when a response is missing or the status code is over a value like 300
func Temporary ¶
func Temporary() Retryer
Temporary retries if the error implements Temporary() bool and returns true or aborts if returning false.
func Timeout ¶
Timeout errors after a duration of time passes since the first attempt.
type TimeoutError ¶
type TimeoutError struct {
// contains filtered or unexported fields
}
TimeoutError is returned from RoundTrip when the time limit has been reached.
func (TimeoutError) Error ¶
func (e TimeoutError) Error() string
type Transport ¶
type Transport struct { // Delay is called for attempts that are retried. If nil, no delay will be used. Delay Delayer // Retry is called for every attempt Retry Retryer // Next is called for every attempt Next http.RoundTripper }
func (Transport) RoundTrip ¶
RoundTrip delegates a RoundTrip, then determines via Retry whether to retry and Delay for the wait time between attempts.
Source Files ¶
- Version
- v0.0.0-20200128134331-0f66f006fb2e (latest)
- Published
- Jan 28, 2020
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 2 months ago –
Tools for package owners.