httpclient

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 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

type Backoff interface {
	Next(retry int) time.Duration
}

Backoff interface defines contract for backoff strategies

type Client

type Client interface {
	Get(url string, headers http.Header) (*http.Response, error)
	Post(url string, body io.Reader, headers http.Header) (*http.Response, error)
	PostForm(url string, val url.Values, headers http.Header) (*http.Response, error)
	Put(url string, body io.Reader, headers http.Header) (*http.Response, error)
	Patch(url string, body io.Reader, headers http.Header) (*http.Response, error)
	Delete(url string, headers http.Header) (*http.Response, error)
	Do(req *http.Request) (*http.Response, error)
	Options() Options
	Clone(opts ...Option) Client
}

Client http client interface

type DoFunc

type DoFunc func(*http.Request, func(*http.Response) error) error

DoFunc http client do func wrapper

type Middleware

type Middleware func(DoFunc) DoFunc

Middleware http client middleware

type Option

type Option func(opts *Options)

Option ...

type Options

type Options struct {
	Retrier    Retriable
	Timeout    time.Duration
	RetryCount int
	Middles    []Middleware
	Transport  http.RoundTripper
}

Options represents the http client options

func (Options) Clone

func (opts Options) Clone() Options

type Retriable

type Retriable interface {
	NextInterval(retry int) time.Duration
}

Retriable defines contract for retriers to implement

type RetriableFunc

type RetriableFunc func(retry int) time.Duration

RetriableFunc is an adapter to allow the use of ordinary functions as a Retriable

func (RetriableFunc) NextInterval

func (f RetriableFunc) NextInterval(retry int) time.Duration

NextInterval calls f(retry)

Jump to

Keyboard shortcuts

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