Documentation ¶
Index ¶
- Constants
- func GetFormatRequestTime(time time.Time) string
- func GetRequestCost(start, end time.Time) float64
- func GetRequestData(requestBody interface{}) (encodeData string, err error)
- func GetUrlData(data map[string]string) (string, error)
- func Str2bytes(s string) []byte
- type ApiConf
- type ApiRequest
- type BackOffPolicy
- type HttpClient
- func (entity *HttpClient) MakeRequest(method, url string, data io.Reader, headers map[string]string, ...) (*http.Request, error)
- func (entity *HttpClient) PreUse(args ...interface{})
- func (entity *HttpClient) Request(method string, uri string, reqBody []byte, header map[string]string, ...) (data []byte, err error)
- type RetryPolicy
Constants ¶
View Source
const ( HttpHeaderService = "SERVICE" // trace 日志前缀标识(放在[]zap.Field的第一个位置提高效率) TopicType = "_tp" // 业务日志名字 LogNameServer = "server" // access 日志文件名字 LogNameAccess = "access" // module 日志文件名字 LogNameModule = "module" TraceHeaderKey = "Uber-Trace-Id" LogIDHeaderKey = "X_BD_LOGID" LogIDHeaderKeyLower = "x_bd_logid" )
Variables ¶
This section is empty.
Functions ¶
func GetFormatRequestTime ¶
func GetRequestCost ¶
func GetRequestData ¶
Types ¶
type ApiConf ¶
type ApiConf struct { Service string `yaml:"service"` AppKey string `yaml:"appkey"` Domain string `yaml:"domain"` Timeout time.Duration `yaml:"timeout"` ConnectTimeout time.Duration `yaml:"connectTimeout"` Retry int `yaml:"retry"` HttpStat bool `yaml:"httpStat"` Proxy string `yaml:"proxy"` BasicAuth struct { Username string `yaml:"username"` Password string `yaml:"password"` } }
func (*ApiConf) GetTransPort ¶
type ApiRequest ¶
type ApiRequest struct { Req *http.Request HTTPClient *http.Client // 重试策略,可不指定,默认使用`defaultRetryPolicy`(只有在`api.yaml`中指定retry>0 时生效) RetryPolicy RetryPolicy // 重试间隔机制,可不指定,默认使用`defaultBackOffPolicy`(只有在`api.yaml`中指定retry>0 时生效) BackOffPolicy BackOffPolicy // contains filtered or unexported fields }
func (*ApiRequest) GetBackOffPolicy ¶
func (entity *ApiRequest) GetBackOffPolicy() BackOffPolicy
func (*ApiRequest) GetRetryPolicy ¶
func (entity *ApiRequest) GetRetryPolicy() RetryPolicy
type HttpClient ¶
func (*HttpClient) MakeRequest ¶
func (*HttpClient) PreUse ¶
func (entity *HttpClient) PreUse(args ...interface{})
Click to show internal directories.
Click to hide internal directories.