Documentation ¶
Overview ¶
Package backoff allows retrying an operation with backoff.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRetryable ¶ added in v1.3.0
IsRetryable returns false unless the error is explicitly retriable per https://godoc.org/google.golang.org/grpc/codes, or if the error codes is in retry. codes.OK is not retryable.
func RetriableErrorf ¶ added in v1.3.0
RetriableErrorf wraps a formatted string into a RetriableError.
Types ¶
type Backoff ¶
type Backoff struct { Min time.Duration // Duration of the first pause. Max time.Duration // Max duration of a pause. Factor float64 // The factor of duration increase between iterations. Jitter bool // Add random noise to pauses. // contains filtered or unexported fields }
Backoff specifies the parameters of the backoff algorithm. Works correctly if 0 < Min <= Max <= 2^62 (nanosec), and Factor >= 1.
func (*Backoff) Duration ¶
Duration returns the time to wait on current retry iteration. Every time Duration is called, the returned value will exponentially increase by Factor until Backoff.Max. If Jitter is enabled, will add an additional random value between 0 and the duration, so the result can at most double.
func (*Backoff) Reset ¶
func (b *Backoff) Reset()
Reset sets the internal state back to first retry iteration.
type RetriableError ¶ added in v1.3.0
type RetriableError string
RetriableError explicitly instructs Backoff to retry.
func (RetriableError) Error ¶ added in v1.3.0
func (re RetriableError) Error() string
Error returns string representation of the retriable error.