backoff

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 2 Imported by: 12

Documentation

Overview

Package backoff provides varies backoff strategies for retry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Strategy

type Strategy func(attempts uint) time.Duration

Strategy is a function that provides the amount of time to wait before trying again. Note: attempts starts at 1

func BinaryExponential

func BinaryExponential(baseDelay time.Duration) Strategy

BinaryExponential returns an Exponential strategy with a base of 2.0

delay = baseDelay * 2^(attempts - 1) Ex. BinaryExponential(2*time.Seconds) = 2s, 4s, 8s, 16s, ...

func Constant

func Constant(interval time.Duration) Strategy

Constant returns a strategy that always returns the provided duration.

func Exponential

func Exponential(baseDelay time.Duration, base float64) Strategy

Exponential returns a strategy that exponentially increases based off of the number of attempts.

delay = baseDelay * base^(attempts - 1) Ex. Exponential(2*time.Seconds, 3) = 2s, 6s, 18s, 54s, ...

func Linear

func Linear(baseDelay time.Duration) Strategy

Linear returns a strategy that linearly increases based off of the number of attempts.

delay = baseDelay * attempts Ex. Linear(2*time.Seconds) = 2s, 4s, 6s, 8s, ...

Jump to

Keyboard shortcuts

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