retry

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package retry reruns fallible operations (network calls, toolchain runs) with capped attempts and backoff. Permanent failures should be returned wrapped so callers can exclude them via Options.RetryIf.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(fn func() error, opts Options) error

Do runs fn until it succeeds or attempts run out, backing off between tries. It returns nil on success, otherwise the last error unwrapped.

Types

type Options

type Options struct {
	// Attempts caps tries including the first call. Default 3.
	Attempts uint
	// Delay is the base backoff between tries. Default time.Second.
	Delay time.Duration
	// RetryIf, when set, vetoes retries for matching errors.
	RetryIf func(error) bool
}

Options tunes Do. Zero value retries 3 times with 1s backoff.

Jump to

Keyboard shortcuts

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