lib

package
v0.0.0-...-f53f79a Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: MIT, GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResultCodePlain

func GetResultCodePlain(code ResultCode) string

Types

type CallResult

type CallResult struct {
	Id     int64         // ID。
	Req    RawReq        // 原生请求。
	Resp   RawResp       // 原生响应。
	Code   ResultCode    // 响应代码。
	Msg    string        // 结果成因的简述。
	Elapse time.Duration // 耗时。
}

调用结果的结构。

type Caller

type Caller interface {
	// 构建请求。
	BuildReq() RawReq
	// 调用。
	Call(req []byte, timeoutNs time.Duration) ([]byte, error)
	// 检查响应。
	CheckResp(rawReq RawReq, rawResp RawResp) *CallResult
}

调用器的接口。

type GenStatus

type GenStatus int

载荷发生器的状态的类型。

const (
	STATUS_ORIGINAL GenStatus = 0
	STATUS_STARTED  GenStatus = 1
	STATUS_STOPPED  GenStatus = 2
)

type Generator

type Generator interface {
	// 启动载荷发生器。
	Start()
	// 停止载荷发生器。
	// 第一个结果值代表已发载荷总数,且仅在第二个结果值为true时有效。
	// 第二个结果值代表是否成功将载荷发生器转变为已停止状态。
	Stop() (uint64, bool)
	// 获取状态。
	Status() GenStatus
}

载荷发生器的接口。

type GoTickets

type GoTickets interface {
	// 拿走一张票。
	Take()
	// 归还一张票。
	Return()
	// 票池是否已被激活。
	Active() bool
	// 票的总数。
	Total() uint32
	// 剩余的票数。
	Remainder() uint32
}

Goroutine票池的接口。

func NewGoTickets

func NewGoTickets(total uint32) (GoTickets, error)

type RawReq

type RawReq struct {
	Id  int64
	Req []byte
}

原生请求的结构。

type RawResp

type RawResp struct {
	Id     int64
	Resp   []byte
	Err    error
	Elapse time.Duration
}

原生响应的结构。

type ResultCode

type ResultCode int
const (
	RESULT_CODE_SUCCESS                         = 0    // 成功。
	RESULT_CODE_WARNING_CALL_TIMEOUT ResultCode = 1001 // 调用超时警告。
	RESULT_CODE_ERROR_CALL           ResultCode = 2001 // 调用错误。
	RESULT_CODE_ERROR_RESPONSE       ResultCode = 2002 // 响应内容错误。
	RESULT_CODE_ERROR_CALEE          ResultCode = 2003 // 被调用方(被测软件)的内部错误。
	RESULT_CODE_FATAL_CALL           ResultCode = 3001 // 调用过程中发生了致命错误!
)

保留 1 ~ 1000 给载荷承受者使用。

Jump to

Keyboard shortcuts

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