pkg

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP2xx = 2
	HTTP4xx = 4
)

Variables

This section is empty.

Functions

func ExpBackoff

func ExpBackoff(interval, max time.Duration) time.Duration

Types

type Err

type Err error

type ErrInvalid

type ErrInvalid struct {
	Err
}

type ErrNetwork

type ErrNetwork struct {
	Err
}

type ErrNotFound

type ErrNotFound struct {
	Err
}

type ErrServer

type ErrServer struct {
	Err
}

type ErrTimeout

type ErrTimeout struct {
	Err
}

type Getter

type Getter interface {
	Get(string) ([]byte, error)
	GetRetry(string) ([]byte, error)
}

type HTTPClient

type HTTPClient struct {
	// Initial backoff duration. Defaults to 50 milliseconds
	InitialBackoff time.Duration

	// Maximum exp backoff duration. Defaults to 5 seconds
	MaxBackoff time.Duration

	// Maximum number of connection retries. Defaults to 15
	MaxRetries int

	// Headers to add to the request.
	Header http.Header
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient() *HTTPClient

func NewHTTPClientHeader

func NewHTTPClientHeader(header http.Header) *HTTPClient

func (*HTTPClient) Get

func (h *HTTPClient) Get(dataURL string) ([]byte, error)

func (*HTTPClient) GetRetry

func (h *HTTPClient) GetRetry(rawurl string) ([]byte, error)

GetRetry fetches a given URL with support for exponential backoff and maximum retries

Jump to

Keyboard shortcuts

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