retry

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backoff

func Backoff(p Policy, attempt int, err error) time.Duration

func FormatInfo

func FormatInfo(info Info) string

func Reason

func Reason(err error) string

func ShouldRetry

func ShouldRetry(p Policy, err error) bool

func Sleep

func Sleep(ctx context.Context, d time.Duration) error

Types

type HTTPError

type HTTPError struct {
	StatusCode int
	Header     http.Header
	Body       string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Info

type Info struct {
	Attempt     int
	MaxAttempts int
	Delay       time.Duration
	StatusCode  int
	Reason      string
	Stage       string
	StreamReset bool
}

type Policy

type Policy struct {
	MaxAttempts       int
	BaseDelay         time.Duration
	MaxDelay          time.Duration
	Jitter            float64
	RespectRetryAfter bool
	RetryNetwork      bool
	RetryStatusCodes  map[int]bool
}

func DefaultPolicy

func DefaultPolicy() Policy

func NormalizePolicy

func NormalizePolicy(p Policy) Policy

type Sleeper

type Sleeper func(context.Context, time.Duration) error

Jump to

Keyboard shortcuts

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