httpclient

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FallbackFunction

func FallbackFunction(err error) error

FallbackFunction for hystrix fallback func

func NewClient

func NewClient(cfg Config, name string) *httpClient

Types

type Config

type Config struct {
	Timeout                time.Duration `default:"3000ms"`
	MaxConcurrentRequests  int           `default:"100"`
	ErrorPercentThreshold  int           `default:"10"`
	SleepWindow            int           `default:"20"`
	RequestVolumeThreshold int           `default:"100"`
	RetryCount             int           `default:"3"`

	BackoffInitialTimeout time.Duration `default:"1000ms"`
	BackoffMaxTimeout     time.Duration `default:"5000ms"`
	BackoffJitterInterval time.Duration `default:"200ms"`
	BackoffExponentFactor float64       `default:"2"`

	ProxyUrl string
}

func DefaultConfig

func DefaultConfig() Config

type HTTPClient

type HTTPClient interface {
	Get(url string, headers map[string]string) (*http.Response, error)
	Post(url string, body io.Reader, headers map[string]string) (res *http.Response, err error)
	Put(url string, body io.Reader, headers map[string]string) (res *http.Response, err error)
	Delete(url string, headers map[string]string) (res *http.Response, err error)
	AddPlugin(plg heimdall.Plugin)
}

Jump to

Keyboard shortcuts

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