Documentation
¶
Overview ¶
Package backoff provides backoff mechanisms
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpBackoffPolicy ¶
type ExpBackoffPolicy struct {
// MinBackoffFactor controls the overlap between consecutive retry interval ranges. When
// set to `2`, there is a guarantee that there will be no overlap. The overlap
// will asymptotically approach 50% the higher the value is set.
MinBackoffFactor float64
// BaseBackoffTime controls the rate of exponential growth. Also, you can calculate the start
// of the very first retry interval range by evaluating the following expression:
// baseBackoffTime / minBackoffFactor * 2
BaseBackoffTime float64
// MaxBackoffTime is the maximum number of seconds to wait for a retry.
MaxBackoffTime float64
// RecoveryInterval controls how many retry interval ranges to step down for an endpoint
// upon success. Increasing this should only be considered when maxBackoffTime
// is particularly high or if our intake team is particularly confident.
RecoveryInterval int
// MaxErrors derived value is the number of errors it will take to reach the maxBackoffTime.
MaxErrors int
}
ExpBackoffPolicy contains parameters and logic necessary to implement an exponential backoff strategy when handling errors.
func (*ExpBackoffPolicy) DecError ¶
func (e *ExpBackoffPolicy) DecError(numErrors int) int
DecError decrements the error counter down to zero at RecoveryInterval rate
func (*ExpBackoffPolicy) GetBackoffDuration ¶
func (e *ExpBackoffPolicy) GetBackoffDuration(numErrors int) time.Duration
GetBackoffDuration returns amount of time to sleep after numErrors error
func (*ExpBackoffPolicy) IncError ¶
func (e *ExpBackoffPolicy) IncError(numErrors int) int
IncError increments the error counter up to MaxErrors
type Policy ¶
type Policy interface {
// GetBackoffDuration returns the backoff duration for the given number of errors
GetBackoffDuration(numErrors int) time.Duration
// IncError increments the number of errors and returns the new value
IncError(numErrors int) int
// DecError decrements the number of errors and returns the new value
DecError(numErrors int) int
}
Policy is the common interface for all backoff policies
Click to show internal directories.
Click to hide internal directories.