httpretry

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package httpretry decides which failed HTTP attempts are worth repeating.

It exists because a single unlucky draw against a flaky host loses a recipe for a whole factory run. Measured on one 23-failure batch, ELEVEN were transient HTTP and nothing else:

x.org (×7)          dial tcp 131.252.210.176:443: i/o timeout
gnu.org/gmp         dial tcp 130.242.124.102:443: i/o timeout
pkg-config          dial tcp 131.252.210.176:443: i/o timeout
freetype.org        502 Bad Gateway
ijg.org             503 Service Temporarily Unavailable

xorg.freedesktop.org is not down — three consecutive requests from a second machine answered 200 in 8.2s, 200 in 2.4s, then timed out. It is flaky, and a factory that gives a flaky host exactly one chance reports its own bad luck as a broken recipe.

The distinction that matters is transient versus answered. A 403 or a 404 is the server telling you something true; repeating it wastes time and hides the real message. A timeout, a reset, or a 5xx is the server failing to answer at all.

Index

Constants

View Source
const Attempts = 3

Attempts is how many times a transient failure is retried before giving up. Three attempts spans ~3s of backoff, which covers the flakiness measured above without turning a genuinely dead host into a slow build.

Variables

This section is empty.

Functions

func Backoff

func Backoff(n int) time.Duration

Backoff is how long to wait before attempt n, counting from 0: 500ms, 1s, 2s.

func Transient

func Transient(err error, status int) bool

Transient reports whether an attempt failed in a way worth repeating. Pass the transport error (nil if the request completed) and the status code (0 if it did not).

Types

This section is empty.

Jump to

Keyboard shortcuts

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