backoff

package
v2.0.0-...-9629169 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package backoff contains some basic implementations and a selector by strategy name

Index

Constants

This section is empty.

Variables

View Source
var DefaultBackoffDuration = time.Second

DefaultBackoffDuration is the duration returned by the DefaultBackoff

Functions

func DefaultBackoff

func DefaultBackoff(_ int) time.Duration

DefaultBackoff always returns DefaultBackoffDuration

func ExponentialBackoff

func ExponentialBackoff(i int) time.Duration

ExponentialBackoff returns ever increasing backoffs by a power of 2

func ExponentialJitterBackoff

func ExponentialJitterBackoff(i int) time.Duration

ExponentialJitterBackoff returns ever increasing backoffs by a power of 2 with +/- 0-33% to prevent sychronized requests.

func LinearBackoff

func LinearBackoff(i int) time.Duration

LinearBackoff returns increasing durations, each a second longer than the last

func LinearJitterBackoff

func LinearJitterBackoff(i int) time.Duration

LinearJitterBackoff returns increasing durations, each a second longer than the last with +/- 0-33% to prevent sychronized requests.

Types

type TimeToWaitBeforeRetry

type TimeToWaitBeforeRetry func(int) time.Duration

TimeToWaitBeforeRetry returns the duration to wait before retrying for the given time

func GetByName

func GetByName(strategy string) TimeToWaitBeforeRetry

GetByName returns the WaitBeforeRetry function implementing the strategy

Jump to

Keyboard shortcuts

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