Documentation
¶
Index ¶
- type Doer
- type DoerFunc
- type Interceptor
- func Log(debugfFunc, errorfFunc func(string, ...interface{})) Interceptor
- func New(interceptors ...Interceptor) Interceptor
- func Retry(tries int) Interceptor
- func Throttle(tick <-chan time.Time) Interceptor
- func UntilStatusCodeIs(status int) Interceptor
- func WhileFails(checkFunc func(*http.Response) error) Interceptor
- func WithInterval(duration time.Duration) Interceptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interceptor ¶
func Log ¶
func Log( debugfFunc, errorfFunc func(string, ...interface{}), ) Interceptor
func New ¶
func New(interceptors ...Interceptor) Interceptor
func Retry ¶
func Retry(tries int) Interceptor
Retry request interceptor, call `Retry(0)` means make a single call with no retry.
func Throttle ¶ added in v0.0.2
func Throttle(tick <-chan time.Time) Interceptor
Throttle provides an interceptor that delays client request waiting for a value from an input channel. Use `time.NewTicker(duration).C` or `time.Tick(duration)` as an input parameter.
Example:
var ( ticker = time.NewTicker(duration) icp = interceptor.New(interceptor.Throttle(ticker.C)).Then(http.DefaultClient) ) icp.Do(req) icp.Do(req) . . . icp.Do(req)
func UntilStatusCodeIs ¶
func UntilStatusCodeIs(status int) Interceptor
UntilStatusCodeIs returns an error until specified response status code is received.
func WhileFails ¶
func WhileFails(checkFunc func(*http.Response) error) Interceptor
WhileFails is one of the configurable parts of retry strategy. Specify the function to check the response and return descriptive error message if needed.
func WithInterval ¶
func WithInterval(duration time.Duration) Interceptor
func (Interceptor) Then ¶
func (icp Interceptor) Then(doer Doer) Doer
func (Interceptor) Use ¶
func (icp Interceptor) Use(interceptors ...Interceptor) Interceptor
Click to show internal directories.
Click to hide internal directories.