lib

package
v0.0.0-...-63bff7e Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RET_CODE_SUCCESS              RetCode = 0    // 成功。
	RET_CODE_WARNING_CALL_TIMEOUT         = 1001 // 调用超时警告。
	RET_CODE_ERROR_CALL                   = 2001 // 调用错误。
	RET_CODE_ERROR_RESPONSE               = 2002 // 响应内容错误。
	RET_CODE_ERROR_CALEE                  = 2003 // 被调用方(被测软件)的内部错误。
	RET_CODE_FATAL_CALL                   = 3001 // 调用过程中发生了致命错误!
)

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

View Source
const (
	// STATUS_ORIGINAL 代表原始。
	STATUS_ORIGINAL uint32 = 0
	// STATUS_STARTING 代表正在启动。
	STATUS_STARTING uint32 = 1
	// STATUS_STARTED 代表已启动。
	STATUS_STARTED uint32 = 2
	// STATUS_STOPPING 代表正在停止。
	STATUS_STOPPING uint32 = 3
	// STATUS_STOPPED 代表已停止。
	STATUS_STOPPED uint32 = 4
)

声明代表载荷发生器状态的常量。

Variables

This section is empty.

Functions

func GetRetCodePlain

func GetRetCodePlain(code RetCode) string

GetRetCodePlain 会依据结果代码返回相应的文字解释。

Types

type CallResult

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

CallResult 表示调用结果的结构。

type Caller

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

Caller 表示调用器的接口。

type Generator

type Generator interface {
	// 启动载荷发生器。
	// 结果值代表是否已成功启动。
	Start() bool
	// 停止载荷发生器。
	// 结果值代表是否已成功停止。
	Stop() bool
	// 获取状态。
	Status() uint32
	// 获取调用计数。每次启动会重置该计数。
	CallCount() int64
}

Generator 表示载荷发生器的接口。

type GoTickets

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

GoTickets 表示Goroutine票池的接口。

func NewGoTickets

func NewGoTickets(total uint32) (GoTickets, error)

NewGoTickets 会新建一个Goroutine票池。

type RawReq

type RawReq struct {
	ID  int64
	Req []byte
}

RawReq 表示原生请求的结构。

type RawResp

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

RawResp 表示原生响应的结构。

type RetCode

type RetCode int

RetCode 表示结果代码的类型。

Jump to

Keyboard shortcuts

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