Documentation ¶
Index ¶
- type Backoff
- type Config
- type Duration
- type HttpClient
- func (c *HttpClient) Do(ctx context.Context, req *http.Request) (response *http.Response, err error)
- func (c *HttpClient) Get(ctx context.Context, url string, headers http.Header) (response *http.Response, err error)
- func (c *HttpClient) Post(ctx context.Context, url string, body io.Reader, headers http.Header) (response *http.Response, err error)
- func (c *HttpClient) SetRetrier(retrier Retriable)
- func (c *HttpClient) SetRetryCount(count int)
- type Retriable
- type RetriableFunc
- type RetryFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Dial Duration // Timeout Duration KeepAlive Duration MaxConns int MaxIdle int RetryCount int }
HttpClient配置
type Duration ¶
func (*Duration) UnmarshalText ¶
将文本转化为Duration结构
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
HttpClient结构
func (*HttpClient) Do ¶
func (c *HttpClient) Do(ctx context.Context, req *http.Request) (response *http.Response, err error)
Do 实现http重传并执行http.do
func (*HttpClient) Get ¶
func (c *HttpClient) Get(ctx context.Context, url string, headers http.Header) (response *http.Response, err error)
Get HttpCllient Get方法实现
func (*HttpClient) Post ¶
func (c *HttpClient) Post(ctx context.Context, url string, body io.Reader, headers http.Header) (response *http.Response, err error)
Post HttpCllient Post方法实现
func (*HttpClient) SetRetrier ¶
func (c *HttpClient) SetRetrier(retrier Retriable)
SetRetrier 设置重连策略
func (*HttpClient) SetRetryCount ¶
func (c *HttpClient) SetRetryCount(count int)
SetRetryCount 设置重连次数
type Retriable ¶
type Retriable interface { NextInterval(retry int) time.Duration Do(fn RetryFunc, retries int) (err error) }
定义retriers接口实现
func NewRetrierFunc ¶
func NewRetrierFunc(f RetriableFunc) Retriable
NewRetrierFunc 返回一个定义了重试函数的retrier
type RetriableFunc ¶
RetriableFunc 可以使用普通函数的适配器
func (RetriableFunc) NextInterval ¶
func (f RetriableFunc) NextInterval(retry int) time.Duration
NextInterval 调用f(retry)
Click to show internal directories.
Click to hide internal directories.