Documentation
¶
Index ¶
- Variables
- type Exponential
- type ExponentialBuilder
- func (e ExponentialBuilder) Factor(factor float64) ExponentialBuilder
- func (e ExponentialBuilder) Init() Exponential
- func (e ExponentialBuilder) Interval(interval time.Duration) ExponentialBuilder
- func (e ExponentialBuilder) Jitter(jitter time.Duration) ExponentialBuilder
- func (e ExponentialBuilder) Max(max time.Duration) ExponentialBuilder
- func (e ExponentialBuilder) MaxAttempts(max int) ExponentialBuilder
Constants ¶
This section is empty.
Variables ¶
var ErrMaxAttemptsReached = errorsext.ErrMaxAttemptsReached
Functions ¶
This section is empty.
Types ¶
type Exponential ¶
type Exponential struct {
// contains filtered or unexported fields
}
Exponential is the final read-only(thread safe) backoff entity
func (Exponential) Duration ¶
func (e Exponential) Duration(attempt int) time.Duration
Duration accepts attempt and returns the backoff duration o sleep for.
func (Exponential) Sleep ¶ added in v1.1.0
func (e Exponential) Sleep(ctx context.Context, attempt int) error
Sleep is a convenience function wrapping Duration and allowing the sleep time to be cancelled via the Context.
This function can also return ErrMaxAttemptsReached if the max attempts have been reached.
type ExponentialBuilder ¶
type ExponentialBuilder struct {
// contains filtered or unexported fields
}
ExponentialBuilder helps to build the final exponential backoff entity
func NewExponential ¶
func NewExponential() ExponentialBuilder
NewExponential create a new exponential backoff builder with sane defaults.
func (ExponentialBuilder) Factor ¶
func (e ExponentialBuilder) Factor(factor float64) ExponentialBuilder
Factor sets a factor for the backoff algorithm.
func (ExponentialBuilder) Init ¶
func (e ExponentialBuilder) Init() Exponential
Init returns a read-only(thread safe) Exponential backoff entity for use.
func (ExponentialBuilder) Interval ¶
func (e ExponentialBuilder) Interval(interval time.Duration) ExponentialBuilder
Interval sets base wait interval for the backoff algorithm.
func (ExponentialBuilder) Jitter ¶
func (e ExponentialBuilder) Jitter(jitter time.Duration) ExponentialBuilder
Jitter sets the maximum jitter for the backoff algorithm.
func (ExponentialBuilder) Max ¶ added in v1.1.0
func (e ExponentialBuilder) Max(max time.Duration) ExponentialBuilder
Max sets the maximum timeout despite the number of attempts. none/zero is the default.
func (ExponentialBuilder) MaxAttempts ¶ added in v1.2.0
func (e ExponentialBuilder) MaxAttempts(max int) ExponentialBuilder
MaxAttempts sets the maximum number of attempts before the Sleep(...) function begins returning ErrMaxAttemptsReached, by default is unlimited.