httpclient

package
v0.0.0-...-e38cb6b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitHttpClientConf

func InitHttpClientConf(conf map[string]config.HttpClientConf)

func InitHttpClientConfWithPorm

func InitHttpClientConfWithPorm(conf map[string]config.HttpClientConf, promClient **broccoliprometheus.Prom)

Types

type Backoff

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

Backoff interface defines contract for backoff strategies

func NewConstantBackoff

func NewConstantBackoff(backoffInterval, maximumJitterInterval time.Duration) Backoff

NewConstantBackoff returns an instance of ConstantBackoff The maximum jitter interval must be more than 1*time.Millisecond

func NewExponentialBackoff

func NewExponentialBackoff(initialTimeout, maxTimeout time.Duration, exponentFactor float64, maximumJitterInterval time.Duration) Backoff

NewExponentialBackoff returns an instance of ExponentialBackoff The maximum jitter interval must be more than 1*time.Millisecond

type Client

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

func DefaultClient

func DefaultClient() *Client

func GetClient

func GetClient(instance string) (*Client, error)

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, url string, headers map[string]string) ([]byte, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string, headers map[string]string) ([]byte, error)

func (*Client) GetHttpClient

func (c *Client) GetHttpClient(instance string) (zhttpclient.Client, error)

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, url string, body io.Reader, headers map[string]string) ([]byte, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, url string, body io.Reader, headers map[string]string) ([]byte, error)

func (*Client) Put

func (c *Client) Put(ctx context.Context, url string, body io.Reader, headers map[string]string) ([]byte, error)

type Retriable

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

Retriable defines contract for retriers to implement

func NewNoRetrier

func NewNoRetrier() Retriable

NewNoRetrier returns a null object for retriable

func NewRetrier

func NewRetrier(backoff Backoff) Retriable

NewRetrier returns retrier with some backoff strategy

func NewRetrierFunc

func NewRetrierFunc(f RetriableFunc) Retriable

NewRetrierFunc returns a retrier with a retry function defined

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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