backoff

package
v0.22.1 Latest Latest
Warning

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

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

Documentation

Overview

Package backoff holds the retry-delay arithmetic and the cancellable wait that runner's retry loops share: startup and warm-pool retries, listener reconnects, runner-removal retries and guest-agent polling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delay

func Delay(failures int, initial, maximum, cooldown time.Duration, cooldownAfter int, sample float64) time.Duration

Delay is the startup-retry wait: Exponential with Jitter, replaced by a flat cooldown once failures reach cooldownAfter.

func Exponential added in v0.14.0

func Exponential(failures int, initial, maximum time.Duration) time.Duration

Exponential is the wait after the given number of consecutive failures: initial for the first, doubling with each further failure, capped at maximum. No failures means no wait.

func Jitter added in v0.14.0

func Jitter(d time.Duration, sample float64) time.Duration

Jitter picks a point in [d/2, d] by sample, clamped to [0, 1], so owners retrying at the same moment spread out instead of retrying in lockstep.

func Sleep added in v0.14.0

func Sleep(ctx context.Context, d time.Duration) error

Sleep waits d, or until ctx ends, whichever comes first; in the latter case it returns ctx's error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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