backoff

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package backoff computes retry delay ladders shared across services.

It is deliberately tiny and dependency-free: a single exponential schedule that callers layer their own policy on top of — a fixed base/ceiling, an attempt counter, and (if they want it) jitter applied to the returned delay.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exponential

func Exponential(base, maxDelay time.Duration, attempt int) time.Duration

Exponential returns the delay for a retry attempt on an exponential ladder: base for the first attempt, doubling once per attempt past the first, capped at maxDelay. An attempt below 1 is treated as 1.

The doubling short-circuits the moment it reaches the cap, so a large attempt returns maxDelay without looping needlessly or overflowing the duration. The first attempt is never clamped — it is always base, even when base already exceeds maxDelay — so a caller reads a recognizable first rung before the cap takes over.

Types

This section is empty.

Jump to

Keyboard shortcuts

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