rq

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultTimeout is the default timeout per request
	DefaultTimeout = time.Second * 5
	// DefaultRetryCount is the default retry count
	DefaultRetryCount = 2
	// GlobalTransport is the global transport
	// NOTE: When using proxy, CREATE A NEW TRANSPORT to avoid affecting requests that do not need proxies.
	GlobalTransport = &http.Transport{
		MaxIdleConns:        1000,
		MaxIdleConnsPerHost: 10,
		IdleConnTimeout:     60 * time.Second,
	}
	// DefaultClient is the default request client
	DefaultClient = resty.New().SetLogger(NewRestyLogger()).
					SetTransport(GlobalTransport).
					SetTimeout(DefaultTimeout).
					SetRetryCount(DefaultRetryCount)
)

Functions

func IsTimeout

func IsTimeout(err error) bool

IsTimeout checks whether err is timeout

func NewClient

func NewClient() *resty.Client

NewClient creates a new resty client using the global transport (with timeout default to 2s and retry at most 2 times)

func NewClientWithTransport

func NewClientWithTransport(tran http.RoundTripper) *resty.Client

NewClientWithTransport creates a new resty client from given transport

func Trace

func Trace(res *resty.Response) resty.TraceInfo

Trace returns trace information about the request

Types

type RestyLogger

type RestyLogger struct {
}

RestyLogger implements resty logger

func NewRestyLogger

func NewRestyLogger() *RestyLogger

func (RestyLogger) Debugf

func (r RestyLogger) Debugf(format string, v ...interface{})

func (RestyLogger) Errorf

func (r RestyLogger) Errorf(format string, v ...interface{})

func (RestyLogger) Warnf

func (r RestyLogger) Warnf(format string, v ...interface{})

Jump to

Keyboard shortcuts

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