Documentation
¶
Overview ¶
Package backoff provides a calculator for backoff with jitter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Atomic ¶
type Atomic struct {
// contains filtered or unexported fields
}
Atomic is a stateful backoff with internal atomic counter.
func (*Atomic) Duration ¶
Duration returns zero for the first attempt and if the time difference between now and the last call to Duration() is greater than the backoff duration, otherwise returns the backoff duration minus the time since last call.
type Backoff ¶
type Backoff struct {
Min time.Duration // Minimum backoff duration (must be greater 0 and Max).
Max time.Duration // Maximum backoff duration.
Factor float64 // Exponential growth factor. Must be greater 1.0.
Jitter float64 // Jitter ratio in [0.0, 1.0]
RandSource RandReader
}
Backoff is a stateless exponential backoff with jitter calculator.
type RandReader ¶
type RandReader interface{ Float64() float64 }
RandReader provides https://pkg.go.dev/math/rand/v2#Float64.
Click to show internal directories.
Click to hide internal directories.