httpr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff added in v0.13.0

type Backoff func(delay, maxDelay time.Duration, retry int) time.Duration

Backoff provides delays between retries with backoff.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps around a standard library *http.Client with added retry functionality.

func NewClient

func NewClient(options ...Option) *Client

NewClient creates and returns a new *Client with the provided options.

func (Client) Do

func (c Client) Do(r *http.Request) (*http.Response, error)

Do sends an HTTP request and returns an HTTP response.

type Option

type Option func(c *Client)

Option is a function that configures a *Client.

func WithRetryPolicy

func WithRetryPolicy(retryPolicy RetryPolicy) Option

WithRetryPolicy sets retry policy for the *Client.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the timeout of the *Client.

func WithTransport

func WithTransport(transport *http.Transport) Option

WithTransport sets the transport for the *Client.

type Retry added in v0.13.0

type Retry func(r *http.Response, err error) bool

Retry is a function that takes an *http.Response and an error and evaluates if a retry should be done.

type RetryPolicy

type RetryPolicy struct {
	Retry      Retry
	Backoff    Backoff
	MinDelay   time.Duration
	MaxDelay   time.Duration
	MaxRetries int
}

RetryPolicy contains rules for retries.

func (RetryPolicy) IsZero added in v0.13.0

func (r RetryPolicy) IsZero() bool

IsZero returns true if the RetryPolicy is the zero value.

Jump to

Keyboard shortcuts

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