Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) GetRestyClient() *resty.Client
- func (c *Client) Header() http.Header
- func (c *Client) HostUrl() string
- func (c *Client) NewPool(logger log.Logger) *Pool
- func (c *Client) NewRequest(method string, url string) *Request
- func (c *Client) Request(request *Request) *Request
- func (c *Client) Send(request *Request)
- func (c *Client) SetError(err interface{}) *Client
- func (c *Client) SetHeader(header, value string) *Client
- func (c *Client) SetRetry(count int, waitTime time.Duration, maxWaitTime time.Duration)
- func (c Client) WithHostUrl(hostUrl string) *Client
- type ErrorWithResponse
- type Logger
- type Pool
- type Request
- func (r *Request) Id() int
- func (r *Request) IsDone() bool
- func (r *Request) IsSent() bool
- func (r *Request) MarkDone(response *Response)
- func (r *Request) MarkSent()
- func (r *Request) OnError(callback ResponseCallback) *Request
- func (r *Request) OnResponse(callback ResponseCallback) *Request
- func (r *Request) OnSuccess(callback ResponseCallback) *Request
- func (r *Request) Send() *Request
- func (r *Request) SetContext(ctx context.Context) *Request
- func (r *Request) SetFormBody(body map[string]string) *Request
- func (r *Request) SetHeader(header string, value string) *Request
- func (r *Request) SetJsonBody(body map[string]string) *Request
- func (r *Request) SetPathParam(param, value string) *Request
- func (r *Request) SetQueryParam(param, value string) *Request
- func (r *Request) SetResult(result interface{}) *Request
- func (r *Request) WaitFor(subRequest *Request)
- type Response
- type ResponseCallback
- type ResponseEventType
- type ResponseListener
- type Sender
Constants ¶
View Source
const ( RequestTimeout = 30 * time.Second HttpTimeout = 30 * time.Second IdleConnTimeout = 30 * time.Second TLSHandshakeTimeout = 10 * time.Second ResponseHeaderTimeout = 20 * time.Second ExpectContinueTimeout = 2 * time.Second KeepAlive = 20 * time.Second MaxIdleConns = 32 RetryCount = 5 RetryWaitTime = 100 * time.Millisecond RetryWaitTimeMax = 3 * time.Second )
View Source
const LoggerPrefix = "HTTP%s\t"
View Source
const REQUESTS_BUFFER_SIZE = 10000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client - http client.
func (*Client) GetRestyClient ¶
func (c *Client) GetRestyClient() *resty.Client
func (Client) WithHostUrl ¶
type ErrorWithResponse ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger for HTTP client.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool of the asynchronous HTTP requests. When processing a response, a new request can be send.
func (*Pool) SetContext ¶
func (*Pool) StartAndWait ¶
type Request ¶
type Request struct { *resty.Request *Response // contains filtered or unexported fields }
func NewRequest ¶
func (*Request) OnError ¶
func (r *Request) OnError(callback ResponseCallback) *Request
func (*Request) OnResponse ¶
func (r *Request) OnResponse(callback ResponseCallback) *Request
func (*Request) OnSuccess ¶
func (r *Request) OnSuccess(callback ResponseCallback) *Request
func (*Request) SetPathParam ¶
func (*Request) SetQueryParam ¶
type Response ¶
type Response struct { *Request *resty.Response // contains filtered or unexported fields }
func NewResponse ¶
func (*Response) HasResponse ¶
type ResponseCallback ¶
type ResponseCallback func(response *Response)
type ResponseEventType ¶
type ResponseEventType int
const ( EventOnSuccess ResponseEventType = iota EventOnError EventOnResponse // always )
type ResponseListener ¶
type ResponseListener struct { Type ResponseEventType Callback ResponseCallback }
func (*ResponseListener) Invoke ¶
func (l *ResponseListener) Invoke(response *Response)
Click to show internal directories.
Click to hide internal directories.