resilient

package
v0.0.0-...-05b786d Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient is a simplified version of http.Client interface

type WrappedHttpClient

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

WrappedHttpClient is a wrapper around HttpClient which retries requests in case of errors. It implements all of public methods available in http.Client

func NewHttpClient

func NewHttpClient(opts ...retry.Option) *WrappedHttpClient

NewHttpClient returns new WrappedHttpClient with default http.Client as upstream. If you want to configure it in anyway use WrapHttpClient instead.

func WrapHttpClient

func WrapHttpClient(client HttpClient, opts ...retry.Option) *WrappedHttpClient

WrapHttpClient returns new WrappedHttpClient with given HttpClient as upstream

func (*WrappedHttpClient) Do

func (c *WrappedHttpClient) Do(req *http.Request) (resp *http.Response, err error)

Do calls Do method of underlying HttpClient and retries according to given options when an error occurs

func (*WrappedHttpClient) Get

func (c *WrappedHttpClient) Get(url string) (*http.Response, error)

Get is copied from http.Client to be compliant with its interface. For more documentation see http.Client.Get

func (*WrappedHttpClient) Head

func (c *WrappedHttpClient) Head(url string) (*http.Response, error)

Head is copied from http.Client to be compliant with its interface. For more documentation see http.Client.Head

func (*WrappedHttpClient) Post

func (c *WrappedHttpClient) Post(url, contentType string, body io.Reader) (*http.Response, error)

Post is copied from http.Client to be compliant with its interface. For more documentation see http.Client.Post

func (*WrappedHttpClient) PostForm

func (c *WrappedHttpClient) PostForm(url string, data url.Values) (*http.Response, error)

PostForm is copied from http.Client to be compliant with its interface. For more documentation see http.Client.PostForm

Jump to

Keyboard shortcuts

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