forgeerr

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 6 Imported by: 0 modules, 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 forgeerr is the forge-neutral retry policy for forge requests that fail. A Failure is a classified forge error (the forge client produces it; for GitHub that is ghclient.Classify, reached through forge.Classify). Policy turns consecutive failures of one operation into the v1alpha1.ForgeError a controller records on its object: when to try again, with exponential backoff, and when to stop and wait for a human retry. It stops at once for a permanent failure, and when the retry window closes for a temporary one. Hint says what an operator should change before retrying.

The package is pure: it reads no clock of its own and talks to nothing. Rate limits are not its concern. They are known waits that controllers hold for (ghclient.LimitOf) without spending attempts.

Index

Constants

View Source
const (
	WindowFlag  = "forge-retry-window"
	WindowUsage = "how long a forge request failing for a temporary reason (a 5xx, a timeout) " +
		"is retried with backoff before it waits for a human retry; permanent failures " +
		"(a ruleset, a missing permission, an archived repository) wait at once"
)

WindowFlag and WindowUsage define the --forge-retry-window flag every controller that calls the forge registers.

View Source
const (
	// DefaultWindow is how long a temporary failure is retried before the
	// operation stalls for a human retry.
	DefaultWindow = time.Hour
)

Retry policy defaults.

Variables

This section is empty.

Functions

func Backoff

func Backoff(attempts int32) time.Duration

Backoff is the wait after the given number of consecutive failures: 30s, doubling, at most 10m.

func Hint

func Hint(reason, operation string, exhausted bool) string

Hint is what an operator should change before retrying operation after a failure of the given reason. exhausted marks a temporary failure whose retry window has closed. The wording follows the operation: what permission it needs, and how a person tries it again (a Retry on the finding, a new backfill, or cleaning up by hand after a demo reset).

func Tally

func Tally(list *[]v1alpha1.ForgeErrorSummary, operation, object string, f Failure, now time.Time)

Tally folds one more failed object into list, the summary of an operation's failures by reason (v1alpha1.ForgeErrorSummary): it adds to the entry for (operation, reason), or starts one. The list stays bounded however many objects fail: an entry keeps a count, the first message and at most MaxForgeErrorSamples distinct object names, and a list holds at most MaxForgeErrorSummaries entries (a failure of a new kind past that is left out; the caller's log line still names it). A tallied failure is one patchy will not retry, so a temporary one gets the exhausted hint.

func Wait

func Wait(e *v1alpha1.ForgeError, now time.Time) (time.Duration, bool)

Wait reports how long until e's next automatic attempt is due. ok is false when there is nothing to wait for: no record, or one already due. A stalled record never comes due by itself; callers check Stalled first.

Types

type Failure

type Failure struct {
	// Reason is a v1alpha1.ForgeReason* constant.
	Reason string
	// Permanent marks a failure retrying cannot fix by itself.
	Permanent bool
	// Message is the forge's explanation, with its detail.
	Message string
}

Failure is one classified forge error.

type Policy

type Policy struct {
	// Window bounds how long a temporary failure is retried, from its first
	// failure. Zero means DefaultWindow.
	Window time.Duration
}

Policy decides when a failing forge operation is tried again, and when it stops.

func (Policy) Record

func (p Policy) Record(prev *v1alpha1.ForgeError, operation string, f Failure, now time.Time) v1alpha1.ForgeError

Record folds one more failure of operation into prev (the operation's current record, or nil) and returns the record to write. A failure of a different operation, or one after a stall a human has since cleared, starts a new run of attempts. The result has RetryAt set while the controller should try again by itself, and StalledAt set once it should not.

func (Policy) RetryWindow

func (p Policy) RetryWindow() time.Duration

RetryWindow is how long a temporary failure is retried: Window, or DefaultWindow when it is unset.

Jump to

Keyboard shortcuts

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