retryhttp

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package retryhttp provides a rate-limit-aware retrying http.RoundTripper for Git provider API clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithReadOnlyPostRetry added in v0.53.0

func WithReadOnlyPostRetry(ctx context.Context) context.Context

WithReadOnlyPostRetry marks a POST request as safe to retry after transient failures. Use it only for requests that perform read-only operations.

func Wrap

func Wrap(base http.RoundTripper, opts Options) http.RoundTripper

Wrap returns a RoundTripper retrying rate-limited (429, or 403 with rate limit headers as used by GitHub) and transient (5xx on idempotent requests and explicitly marked read-only POSTs) failures with jittered exponential backoff. Retry-After and X-RateLimit-Reset headers are honored, capped at opts.MaxWait.

Types

type Options

type Options struct {
	// MaxAttempts is the maximum number of attempts (initial request included).
	MaxAttempts int
	// MaxWait caps the wait between attempts. If a rate limit reset is
	// further away than MaxWait, the transport gives up instead of blocking.
	MaxWait time.Duration
	// Logger is optional, used to log retries.
	Logger *zap.SugaredLogger
}

Options configures the retry transport.

Jump to

Keyboard shortcuts

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