retry

package module
v0.0.0-...-8473e07 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 4 Imported by: 0

README

retry

repeat the http request until it succeeds

Documentation

Index

Constants

View Source
const (
	SuccessInt = 0
)
View Source
const (
	SuccessStr = "E000"
)

Variables

This section is empty.

Functions

func CodeIntError

func CodeIntError(resp *req.Resp, err error) bool

CodeError

func CodeStrError

func CodeStrError(resp *req.Resp, err error) bool

func Delete

func Delete(url string, v ...interface{}) (*req.Resp, error)

Delete execute a http DELETE request

func Get

func Get(url string, v ...interface{}) (*req.Resp, error)

Get execute a http GET request

func Head(url string, v ...interface{}) (*req.Resp, error)

Head execute a http HEAD request

func HttpStatusError

func HttpStatusError(resp *req.Resp, err error) bool

func NetworkError

func NetworkError(resp *req.Resp, err error) bool

RetryCondFunc 1. network error

func Options

func Options(url string, v ...interface{}) (*req.Resp, error)

Options execute a http OPTIONS request

func Patch

func Patch(url string, v ...interface{}) (*req.Resp, error)

Patch execute a http PATCH request

func Post

func Post(url string, v ...interface{}) (*req.Resp, error)

Post execute a http POST request

func Put

func Put(url string, v ...interface{}) (*req.Resp, error)

Put execute a http PUT request

Types

type RetryClient

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

func NewRetryClient

func NewRetryClient(maxRetry int, retryIntervalFunc RetryIntervalFunc,
	retryCondFunc RetryCondFunc) *RetryClient

func (*RetryClient) Delete

func (r *RetryClient) Delete(url string, v ...interface{}) (*req.Resp, error)

Delete execute a http DELETE request

func (*RetryClient) Do

func (r *RetryClient) Do(method, url string, v ...interface{}) (out *req.Resp, err error)

Do execute request.

func (*RetryClient) Get

func (r *RetryClient) Get(url string, v ...interface{}) (*req.Resp, error)

Get execute a http GET request

func (*RetryClient) Head

func (r *RetryClient) Head(url string, v ...interface{}) (*req.Resp, error)

Head execute a http HEAD request

func (*RetryClient) Options

func (r *RetryClient) Options(url string, v ...interface{}) (*req.Resp, error)

Options execute a http OPTIONS request

func (*RetryClient) Patch

func (r *RetryClient) Patch(url string, v ...interface{}) (*req.Resp, error)

Patch execute a http PATCH request

func (*RetryClient) Post

func (r *RetryClient) Post(url string, v ...interface{}) (*req.Resp, error)

Post execute a http POST request

func (*RetryClient) Put

func (r *RetryClient) Put(url string, v ...interface{}) (*req.Resp, error)

Put execute a http PUT request

type RetryCondFunc

type RetryCondFunc func(*req.Resp, error) bool

type RetryIntervalFunc

type RetryIntervalFunc func(counter int) time.Duration

RetryIntervalFunc : The value of counter starts from 1

func ConstantInterval

func ConstantInterval(interval time.Duration) RetryIntervalFunc

RetryIntervalFunc : The value of counter starts from 1

func ExponentInterval

func ExponentInterval(interval time.Duration) RetryIntervalFunc

type StdIntResp

type StdIntResp struct {
	Code int `json:"code"`
}

type StdStrResp

type StdStrResp struct {
	Code string `json:"code"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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