retry

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package retry provides exponential backoff with jitter. It is a policy calculator, not a loop runner: callers own their loops and contexts and ask Backoff what to wait. The same curve serves transport reconnection in core and the supervisor's crash-loop damping.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff struct {
	// Initial is the base delay for attempt 0.
	Initial time.Duration
	// Max caps the computed delay.
	Max time.Duration
	// Factor multiplies the delay each attempt. Typically 2.
	Factor float64
}

Backoff computes exponentially growing delays with full jitter. The zero value is not usable; use New or fill every field.

func New

func New() Backoff

New returns a Backoff with the conventional platform curve: 1s initial, doubling, capped at 2 minutes.

func (Backoff) Delay

func (b Backoff) Delay(attempt int) time.Duration

Delay returns the wait before the given attempt (0-based), with full jitter: a uniform draw from (0, computed]. Full jitter avoids thundering herds when many modules restart together.

Jump to

Keyboard shortcuts

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