backoff

package
v5.0.0-rc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2021 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package backoff provides stateless methods of calculating durations based on a number of attempts made.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm = func(attempt uint) time.Duration

Algorithm defines a function that calculates a time.Duration based on the given retry attempt number.

func BinaryExponential

func BinaryExponential(factor time.Duration) Algorithm

BinaryExponential creates an Algorithm that multiplies the factor duration by an exponentially increasing factor for each attempt, where the factor is calculated as 2 raised to the attempt number (2^attempt).

func Constant

func Constant(duration time.Duration) Algorithm

Constant creates an Algorithm that returns the initial duration by the all time.

func Exponential

func Exponential(factor time.Duration, base float64) Algorithm

Exponential creates an Algorithm that multiplies the factor duration by an exponentially increasing factor for each attempt, where the factor is calculated as the given base raised to the attempt number.

func Fibonacci

func Fibonacci(factor time.Duration) Algorithm

Fibonacci creates an Algorithm that multiplies the factor duration by an increasing factor for each attempt, where the factor is the Nth number in the Fibonacci sequence.

func Incremental

func Incremental(initial, increment time.Duration) Algorithm

Incremental creates an Algorithm that increments the initial duration by the given increment for each attempt.

func Linear

func Linear(factor time.Duration) Algorithm

Linear creates an Algorithm that linearly multiplies the factor duration by the attempt number for each attempt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL