Documentation
¶
Index ¶
- Constants
- Variables
- func GetZipData(response *http.Response) (body []byte, err error)
- func Http(chanId int, ch chan<- *RequestResults, totalNumber uint64, wg *sync.WaitGroup, ...)
- func HttpJson(request *Request, response *http.Response) (code int, isSucceed bool)
- func HttpMulti(chanId int, ch chan<- *RequestResults, totalNumber uint64, wg *sync.WaitGroup, ...)
- func HttpRequest(method, url string, body io.Reader, headers utils.ConcurrentMap, ...) (resp *http.Response, requestTime uint64, err error)
- func HttpStatusCode(request *Request, response *http.Response) (code int, isSucceed bool)
- func MallVersionJson(request *Request, response *http.Response) (code int, isSucceed bool)
- func ReceivingResults(concurrent int, ch <-chan *RequestResults, wg *sync.WaitGroup)
- func RegisterVerifyHttp(verify string, verifyFunc VerifyHttp)
- func RegisterVerifyWebSocket(verify string, verifyFunc VerifyWebSocket)
- func WebSocket(chanId int, ch chan<- *RequestResults, totalNumber uint64, wg *sync.WaitGroup, ...)
- func WebSocketJson(request *Request, seq string, msg []byte) (code int, isSucceed bool)
- type MallVersion
- type Req
- type ReqListWeigh
- type Request
- type RequestResults
- type ResponseJson
- type Verify
- type VerifyHttp
- type VerifyWebSocket
- type WebSocketC
- type WebSocketResponseJson
Constants ¶
const ( HttpOk = 200 // 请求成功 RequestTimeout = 506 // 请求超时 RequestErr = 509 // 请求错误 ParseError = 510 // 解析错误 FormTypeHttp = "http" FormTypeWebSocket = "webSocket" DefaultMethod = "GET" DefaultVerifyCode = "statusCode" DefaultTimeOut = 30 * time.Second )
Variables ¶
var ( Concurrency int // Concurrency is 并发请求数 Number uint64 // Number is 单个协程的请求总数 Debug bool // Debug is 是否开其调试模式 Path string // Path is curl 文件路径 VerifyStr string // VerifyStr is 验证方法 RequestUrl string // RequestUrl is 压力测试的Url Header []string // Header is 自定义头信息传递给服务器 Body string // Body is HTTP POST data 上传的数据 Compressed bool // Compressed is curl zip algorithm )
Functions ¶
func GetZipData ¶ added in v1.1.1
处理gzip压缩
func Http ¶
func Http(chanId int, ch chan<- *RequestResults, totalNumber uint64, wg *sync.WaitGroup, request *Request)
Http is http go link
func HttpJson ¶ added in v1.0.3
HttpJson is 通过返回的Body 判断 返回示例: {"code":200,"msg":"Success","data":{}} code 默认将http code作为返回码,http code 为200时 取body中的返回code
func HttpMulti ¶ added in v1.1.1
func HttpMulti(chanId int, ch chan<- *RequestResults, totalNumber uint64, wg *sync.WaitGroup, request *Request)
HttpMulti is 处理行数大于100的逻辑。
func HttpRequest ¶ added in v1.0.3
func HttpRequest(method, url string, body io.Reader, headers utils.ConcurrentMap, timeout time.Duration) (resp *http.Response, requestTime uint64, err error)
HttpRequest is HTTP 请求 method 方法 GET POST url 请求的url body 请求的body headers 请求头信息 timeout 请求超时时间
func HttpStatusCode ¶ added in v1.0.3
HttpStatusCode is 通过Http状态码判断是否请求成功
func MallVersionJson ¶ added in v1.0.3
MallVersionJson 通过返回的Body 判断
func ReceivingResults ¶
func ReceivingResults(concurrent int, ch <-chan *RequestResults, wg *sync.WaitGroup)
ReceivingResults is 接收结果并处理 统计的时间都是纳秒,显示的时间 都是毫秒 concurrent 并发数
func RegisterVerifyHttp ¶
func RegisterVerifyHttp(verify string, verifyFunc VerifyHttp)
RegisterVerifyHttp is 注册http校验函数
func RegisterVerifyWebSocket ¶
func RegisterVerifyWebSocket(verify string, verifyFunc VerifyWebSocket)
RegisterVerifyWebSocket is 注册webSocket校验函数
func WebSocket ¶
func WebSocket(chanId int, ch chan<- *RequestResults, totalNumber uint64, wg *sync.WaitGroup, request *Request, ws *WebSocketC)
WebSocket is web socket go link
Types ¶
type MallVersion ¶ added in v1.0.3
type MallVersion struct { Status int `json:"status"` Result string `json:"result"` TraceId string `json:"traceId"` DevMessage string `json:"devMessage"` Message string `json:"message"` Url string `json:"url"` }
MallVersion is for mall.youpenglai.com/apis/version
type ReqListWeigh ¶
type ReqListWeigh struct {
// contains filtered or unexported fields
}
ReqListWeigh 接口加权压测
type Request ¶
type Request struct { Url string // Url Form string // http/webSocket/tcp Method string // 方法 GET/POST/PUT Headers utils.ConcurrentMap // Headers Body string // body Verify string // 验证的方法 Timeout time.Duration // 请求超时时间 Debug bool // 是否开启Debug模式 }
Request is a form for http request 请求结果
func GetRequestListFromFile ¶
func NewRequest ¶
func NewRequest(url string, verify string, timeout time.Duration, debug bool, reqHeaders []string, reqBody string) (request *Request, err error)
NewRequest is get Request form url 压测的url verify 验证方法 在server/verify中 http 支持:statusCode、json webSocket支持:json timeout 请求超时时间 debug 是否开启debug path curl文件路径 http接口压测,自定义参数设置
func (*Request) GetVerifyHttp ¶
func (r *Request) GetVerifyHttp() VerifyHttp
GetVerifyHttp is 获取数据校验方法
func (*Request) GetVerifyWebSocket ¶
func (r *Request) GetVerifyWebSocket() VerifyWebSocket
GetVerifyWebSocket is 获取数据校验方法
func (*Request) IsParameterLegal ¶
IsParameterLegal is verify param is legal
type RequestResults ¶
type RequestResults struct { Id string // 消息Id ChanId int // 消息Id Time uint64 // 请求时间 纳秒 IsSucceed bool // 是否请求成功 ErrCode int // 错误码 }
RequestResults is 请求结果
func (*RequestResults) SetId ¶
func (r *RequestResults) SetId(chanId int, number uint64)
SetId is set chanId & id to request results
type ResponseJson ¶ added in v1.0.3
type ResponseJson struct { Code int `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` }
返回数据结构体
type VerifyHttp ¶
VerifyHttp is verify for http 验证方法
type VerifyWebSocket ¶
VerifyWebSocket is verify for websocket
type WebSocketC ¶ added in v1.0.3
type WebSocketC struct { UrlLink string Url *url.URL IsSsl bool // contains filtered or unexported fields }
WebSocketC is client for websocket
func NewWebSocket ¶ added in v1.0.3
func NewWebSocket(urlLink string) (ws *WebSocketC)
NewWebSocket is get WebSocketC
func (*WebSocketC) GetConn ¶ added in v1.0.3
func (w *WebSocketC) GetConn() (err error)
GetConn is get connection
func (*WebSocketC) Read ¶ added in v1.0.3
func (w *WebSocketC) Read() (msg []byte, err error)
Read is 接收数据
func (*WebSocketC) Write ¶ added in v1.0.3
func (w *WebSocketC) Write(body []byte) (err error)
Write is 发送数据