retry

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package retry provides explicit opt-in HTTP retry transports for providers.

The default SDK behavior is no retry. Provider configs expose Retry for the simple path; this package is also available for advanced transport composition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(base *http.Client, policy *Policy) *http.Client

NewHTTPClient returns a shallow copy of base whose Transport is wrapped by NewTransport. Provider Config.Retry is the preferred user-facing API.

func NewTransport

func NewTransport(base http.RoundTripper, policy *Policy) http.RoundTripper

NewTransport wraps base with retry behavior. A nil policy, MaxAttempts <= 1, or nil base keeps behavior simple: no retry or http.DefaultTransport.

Types

type Policy

type Policy struct {
	MaxAttempts       int
	InitialDelay      time.Duration
	MaxDelay          time.Duration
	Multiplier        float64
	Jitter            bool
	RespectRetryAfter bool
}

func DefaultPolicy

func DefaultPolicy() *Policy

DefaultPolicy returns a conservative retry policy for complete retryable HTTP responses. It does not retry network write/read errors because a POST may already have been processed by the provider.

type Transport

type Transport struct {
	Base   http.RoundTripper
	Policy Policy
}

Transport retries complete 429/5xx/529 responses according to Policy. It requires replayable request bodies for retries.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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