backoff

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package backoff provides retry delay policies.

Index

Constants

View Source
const (
	DefaultBase = time.Second
	DefaultCap  = 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Constant

type Constant struct{ D time.Duration }

func (Constant) Delay

func (c Constant) Delay(int) time.Duration

type Exponential

type Exponential struct {
	Base time.Duration
	Cap  time.Duration
	Rand func() float64
}

Exponential is an exponential delay with full jitter.

func NewExponential

func NewExponential() Exponential

NewExponential returns the default policy.

func (Exponential) Ceiling

func (e Exponential) Ceiling(attempt int) time.Duration

func (Exponential) Delay

func (e Exponential) Delay(attempt int) time.Duration

type Func

type Func func(attempt int) time.Duration

func (Func) Delay

func (f Func) Delay(attempt int) time.Duration

type Policy

type Policy interface {
	Delay(attempt int) time.Duration
}

Policy returns the delay before the next attempt of a failed job.

Jump to

Keyboard shortcuts

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