Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backoff ¶
type Backoff interface { // NextInterval returns an interval before the next process is executed. NextInterval() time.Duration // Reset resets backoff to its initial state. Reset() }
Backoff is an interface for backoff-strategy.
type ConstantBackoff ¶
type ConstantBackoff struct { // BackoffInterval defines how long the next interval will be, compared to the previous one. BackoffInterval time.Duration // JitterInterval defines the additional value for interval. // The additional value will be in range [0,JitterInterval). JitterInterval time.Duration }
ConstantBackoff implements Backoff using constant interval.
func (*ConstantBackoff) NextInterval ¶
func (c *ConstantBackoff) NextInterval() time.Duration
NextInterval returns next interval.
func (*ConstantBackoff) Reset ¶
func (c *ConstantBackoff) Reset()
Reset resets Constant Backoff. Actually, it does nothing since constant backoff will always constant all the time.
type ExponentialBackoff ¶
type ExponentialBackoff struct { // BackoffInterval defines how long the next interval will be, compared to the previous one. BackoffInterval time.Duration // JitterInterval defines the additional value for interval. // The additional value will be in range [0,JitterInterval). JitterInterval time.Duration // MaxInterval defines the maximum interval allowed. // If this field is let empty, // it means that there is no maximum value for interval. // Please, keep in mind that if this field is empty, // the interval can be a very long time. MaxInterval time.Duration // Multipler defines the multipler for the next interval. // Default value for Multiplier is 1. // Using `Multiplier = 1` means ExponentialBackoff can behave // like ConstantBackoff. Multiplier int // contains filtered or unexported fields }
ExponentialBackoff implements Backoff using exponential interval.
func (*ExponentialBackoff) NextInterval ¶
func (e *ExponentialBackoff) NextInterval() time.Duration
NextInterval returns next interval.
func (*ExponentialBackoff) Reset ¶
func (e *ExponentialBackoff) Reset()
Reset resets Exponential Backoff.
Click to show internal directories.
Click to hide internal directories.