core

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagUUID   = "uuid"
	TagInt    = "int"
	TagString = "string"
	TagFloat  = "float"
	TagIncr   = "incr"
	TagList   = "list:"
	TagRange  = "range:"
)
View Source
const (
	DebugRequestMessageFormat  = "Request Message : %+v \n"
	DebugRequestErrorFormat    = "Request Error : %s \n"
	DebugResponseMessageFormat = "Response Message : %s \n"
)

Variables

This section is empty.

Functions

func GenerateTlsConfig

func GenerateTlsConfig(host string, rootCA *x509.Certificate, rootKey *rsa.PrivateKey) (*tls.Config, error)

Types

type BenchmarkExecDuration

type BenchmarkExecDuration struct {
	BenchmarkReqConfig
	Executor
	// contains filtered or unexported fields
}

func (*BenchmarkExecDuration) Run

func (exec *BenchmarkExecDuration) Run() error

type BenchmarkExecTimes

type BenchmarkExecTimes struct {
	BenchmarkReqConfig
	Executor
	// contains filtered or unexported fields
}

func (*BenchmarkExecTimes) Run

func (exec *BenchmarkExecTimes) Run() error

type BenchmarkExecutor

type BenchmarkExecutor interface {
	Run() error // using goroutine pool
	ClearHopHeaders(header http.Header) http.Header
	Result() *Statistic
}

func NewExecutor

func NewExecutor(req *http.Request) BenchmarkExecutor

type BenchmarkExecutorType

type BenchmarkExecutorType int

type BenchmarkProxyHeader

type BenchmarkProxyHeader struct {
	ExecTimes       int
	ExecDuration    time.Duration
	ExecConcurrency int
	ResponseChecker *ResponseChecker
}

func NewProxyHeader

func NewProxyHeader(header http.Header) *BenchmarkProxyHeader

type BenchmarkProxyService

type BenchmarkProxyService struct {
	// contains filtered or unexported fields
}

func NewBenchProxyService

func NewBenchProxyService(port int, rootCA *x509.Certificate, rootKey *rsa.PrivateKey) *BenchmarkProxyService

func (*BenchmarkProxyService) Serve

func (s *BenchmarkProxyService) Serve()

func (*BenchmarkProxyService) ServeHTTP

func (s *BenchmarkProxyService) ServeHTTP(originRespWriter http.ResponseWriter, originReq *http.Request)

func (*BenchmarkProxyService) WrapInTls

func (s *BenchmarkProxyService) WrapInTls(originReq *http.Request, originRespWriter http.ResponseWriter, fn func(originReq *http.Request, originRespWriter http.ResponseWriter))

type BenchmarkReqConfig

type BenchmarkReqConfig struct {
	// contains filtered or unexported fields
}

func (*BenchmarkReqConfig) ClearHopHeaders

func (config *BenchmarkReqConfig) ClearHopHeaders(originHeader http.Header) http.Header

type BenchmarkRespWriter

type BenchmarkRespWriter struct {
	*tls.Conn
}

func (*BenchmarkRespWriter) Header

func (t *BenchmarkRespWriter) Header() http.Header

func (*BenchmarkRespWriter) WriteHeader

func (t *BenchmarkRespWriter) WriteHeader(statusCode int)

type DurationInfo added in v0.0.26

type DurationInfo struct {
	Total            int64
	DNSLookup        int64
	TCPConnection    int64
	TLSHandshake     int64
	ServerProcessing int64
	ContentTransfer  int64
}

func NewDurationInfo added in v0.0.26

func NewDurationInfo(t *HttpTracer) DurationInfo

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

func (*Executor) ReplaceCustomizeTag

func (exec *Executor) ReplaceCustomizeTag(urlParser, bodyParser *TagCompoundParser, req *http.Request)

func (*Executor) Result

func (exec *Executor) Result() *Statistic

func (*Executor) RunOnce

func (exec *Executor) RunOnce(req *http.Request, checker *ResponseChecker) (HttpTracerResult, error)

type HttpTracer

type HttpTracer struct {
	DNSStart             time.Time
	DNSDone              time.Time
	ConnectStart         time.Time
	ConnectDone          time.Time
	GotConn              time.Time
	GotFirstResponseByte time.Time
	TLSHandShakeStart    time.Time
	TLSHandSHakeDone     time.Time
}

func (*HttpTracer) Result

func (t *HttpTracer) Result(req *http.Request, resp *http.Response, checker *ResponseChecker) HttpTracerResult

func (*HttpTracer) Trace

func (t *HttpTracer) Trace() *httptrace.ClientTrace

type HttpTracerResult

type HttpTracerResult struct {
	IsSuccess       bool
	ResponseMessage string
	RequestDataLen  int64
	ResponseDataLen int64
	Duration        DurationInfo
}

type Pair

type Pair struct {
	Cert            *x509.Certificate
	CertBytes       []byte
	PrivateKey      *rsa.PrivateKey
	PrivateKeyBytes []byte
}

func GeneratePem

func GeneratePem(host string, expireDay int, rootCA *x509.Certificate, rootKey *rsa.PrivateKey) (*Pair, error)

GeneratePem 生成证书

type Pool added in v0.0.26

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool added in v0.0.26

func NewPool(cap int) *Pool

type ResponseCheckOption added in v0.0.24

type ResponseCheckOption func(checker *ResponseChecker)

func ResponseCheckerBodyRule added in v0.0.24

func ResponseCheckerBodyRule(body string) ResponseCheckOption

func ResponseCheckerStatusRule added in v0.0.24

func ResponseCheckerStatusRule(status int) ResponseCheckOption

type ResponseChecker added in v0.0.24

type ResponseChecker struct {
	// contains filtered or unexported fields
}

func NewResponseChecker added in v0.0.24

func NewResponseChecker(options ...ResponseCheckOption) *ResponseChecker

func (*ResponseChecker) Check added in v0.0.26

func (c *ResponseChecker) Check(responseStatus int, responseMessage string) bool

type Statistic

type Statistic struct {
	Durations    []DurationInfo
	SuccessCount int32
	FailCount    int32
	Total        int32
	// contains filtered or unexported fields
}

func (*Statistic) Aggregate

func (s *Statistic) Aggregate(tracerResultChan <-chan HttpTracerResult)

func (*Statistic) Print

func (s *Statistic) Print() []byte

func (*Statistic) PrintBuf

func (s *Statistic) PrintBuf() []byte

type TagCompoundParser

type TagCompoundParser struct {
	// contains filtered or unexported fields
}

func NewTagCompoundParser

func NewTagCompoundParser() *TagCompoundParser

func (*TagCompoundParser) ParseCustomizeTag

func (p *TagCompoundParser) ParseCustomizeTag(content string) string

type Task added in v0.0.26

type Task struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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