transient

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package transient retries a read from a forge that failed for a reason that can pass by itself: a timeout, a refused or reset connection, or a busy server.

Index

Constants

View Source
const Attempts = 4

Attempts bounds Retry, the first attempt included.

Variables

This section is empty.

Functions

func Is

func Is(err error) bool

Is reports whether err is a failure worth trying again: a timeout, a reset or refused connection, or a 500, 502, 503 or 504. A run out of its own time is not, since trying again cannot give it more.

Only a failure before the forge answers can be recognised. go-git v5 flattens an error met while decoding the response into text.

func Jittered

func Jittered(attempt int) time.Duration

Jittered waits between one and three seconds per attempt already made, so jobs that hit the same outage do not come back in lockstep.

func Retry

func Retry(ctx context.Context, pause Pause, op func() error) error

Retry runs op until it succeeds, fails for a reason Is rejects, or has run Attempts times. Only a read is safe to hand it: a write that failed partway may have landed.

Types

type Pause

type Pause func(attempt int) time.Duration

Pause is how long to wait before the given attempt, counting the first retry as attempt 1.

Jump to

Keyboard shortcuts

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