Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomTimer ¶
type CustomTimer struct {
// contains filtered or unexported fields
}
CustomTimer represents a backoff timer configured with a certain DelayProvider.
func NewCustomTimer ¶
func NewCustomTimer(delayProvider DelayProvider) *CustomTimer
NewCustomTimer creates a new custom timer using the provided delay provider.
func (*CustomTimer) Close ¶
func (t *CustomTimer) Close()
Close cleans up the resources used by this timer. It cannot be reused after this call.
func (*CustomTimer) CurrentDelay ¶
func (t *CustomTimer) CurrentDelay() time.Duration
CurrentDelay returns the delay of the current or last ticked retry.
func (*CustomTimer) NumRetries ¶
func (t *CustomTimer) NumRetries() int
NumRetries returns the number of tries since this timer was last reset.
func (*CustomTimer) ReceiveTick ¶
func (t *CustomTimer) ReceiveTick() <-chan time.Time
ReceiveTick returns a channel that will receive a time.Time object as soon as the previously scheduled retry ticks.
func (*CustomTimer) Reset ¶
func (t *CustomTimer) Reset()
Reset stops and resets the number of retries counter of this timer.
func (*CustomTimer) ScheduleRetry ¶
func (t *CustomTimer) ScheduleRetry(err error) (int, time.Duration)
ScheduleRetry schedules the next retry tick according to the delay provider, returning retry num and retry delay.
func (*CustomTimer) Stop ¶
func (t *CustomTimer) Stop()
Stop prevents any current scheduled retry from ticking.
type DelayProvider ¶
DelayProvider is a function that takes the current numRetries and last error and returns the delay until next retry.
func DefaultExponentialDelayProvider ¶
func DefaultExponentialDelayProvider() DelayProvider
DefaultExponentialDelayProvider creates a new instance of an ExponentialDelayProvider using the default config.
func ExponentialDelayProvider ¶
func ExponentialDelayProvider(conf ExponentialConfig) DelayProvider
ExponentialDelayProvider creates a new instance of an ExponentialDelayProvider using the provided config.
type ExponentialConfig ¶
ExponentialConfig holds the parameters used by the ExponentialTimer.
func DefaultExponentialConfig ¶
func DefaultExponentialConfig() ExponentialConfig
DefaultExponentialConfig creates an ExponentialConfig with default values.
type ExponentialTimer ¶
type ExponentialTimer struct {
CustomTimer
}
ExponentialTimer performs an exponential backoff following the FullJitter implementation described in https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
func NewCustomExponentialTimer ¶
func NewCustomExponentialTimer(conf ExponentialConfig) *ExponentialTimer
NewCustomExponentialTimer creates an exponential backoff timer using the provided configuration.
func NewExponentialTimer ¶
func NewExponentialTimer() *ExponentialTimer
NewExponentialTimer creates an exponential backoff timer using the default configuration.