stress

package
v0.0.0-...-c802062 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckError = base.CheckError

Functions

func DecodeCheckJSONBody

func DecodeCheckJSONBody(w http.ResponseWriter, r *http.Request, v interface{}) (err error)

func ExecuteGet

func ExecuteGet(url string, rc *RequestContext)

func ExecuteRequest

func ExecuteRequest(req *http.Request, rc *RequestContext)

func HttpError

func HttpError(w http.ResponseWriter, code int, msg ...string)

func IsServerClosedIdle

func IsServerClosedIdle(err error) bool

func ListenAndServe

func ListenAndServe(addr string, routes []*Route, tlsConfig *tls.Config)

func MarshalIndent

func MarshalIndent(v interface{}) []byte

func Match2Map

func Match2Map(m []int, s string, pat *regexp.Regexp) map[string]string

func NewEvent

func NewEvent() *sync.WaitGroup

.Done() and .Wait() may be implemented via channels like so: jobsEnded := make(chan struct{}) close(jobsEnded) // = .Done() <-jobsEnded // = .Wait()

But channels may be select-ed and wg's - not. So, if you do not use select then WaitGroup is just a sufficient match

func NewServerTLSConfig

func NewServerTLSConfig(fname string) *tls.Config

func NewTLSConfig

func NewTLSConfig(tlsFname string) *tls.Config

func PrintReport

func PrintReport(stats *StatsType, stressTimes StressTimes, aggregationCount int)

func RaiseHttpError

func RaiseHttpError(code int, msg ...string)

func Serve

func Serve(addr string, appRoutes Routes, serveData *ServeData, tlsConfig *tls.Config)

func ServeDummyHTTP

func ServeDummyHTTP(targetUrl string, route *Route, serverTLSConfigFname string)

func ServeJSON

func ServeJSON(w http.ResponseWriter, code int, jsonBytes []byte)

Types

type CheckData

type CheckData struct {
	Version       string    `json:"version"`
	Start         time.Time `json:"start"`
	UptimeSeconds float64   `json:"uptime_seconds"`
}

func MakeCheckData

func MakeCheckData(version string) CheckData

type Duration

type Duration time.Duration

func (Duration) MarshalText

func (d Duration) MarshalText() (text []byte, err error)

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request, Match)

type HttpException

type HttpException struct {
	Code     int
	Messages []string
}

type JobContext

type JobContext struct {
	StartJob func(jobFunc func())
	Wait     func()
}

func NewJobContext

func NewJobContext() *JobContext

type Match

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

func (Match) Arguments

func (match Match) Arguments() []string

func (Match) GetArgumentsMap

func (match Match) GetArgumentsMap() map[string]string

type RequestContext

type RequestContext struct {
	Client *http.Client
	Stats  *StatsType

	IncrStat func(msg string, dur float64)

	WaitStatsReady func()
}

func NewRequestContext

func NewRequestContext() *RequestContext

func NewRequestContextEx

func NewRequestContextEx(rco *RequestContextOptions) *RequestContext

type RequestContextOptions

type RequestContextOptions struct {
	KeepAlive     bool
	StressTimeout float64
	TLSConfigFile string
}

type Route

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

func NewRoute

func NewRoute(pattern string, handler HandlerFunc) *Route

type RouteFunc

type RouteFunc func(pattern string, handler HandlerFunc, optHelp ...string) *Route

func GenerateMakeRoute

func GenerateMakeRoute(serveData *ServeData) RouteFunc

type RouteHelp

type RouteHelp struct {
	Pattern string
	Help    string
}

type Routes

type Routes []*Route

type ServeData

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

func NewServeData

func NewServeData(version string) *ServeData

type ServerHandler

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

func (*ServerHandler) ServeHTTP

func (handler *ServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServerTLSConfig

type ServerTLSConfig struct {
	CA   string `toml:"ca"`
	Cert string `toml:"cert"`
	Key  string `toml:"key"`
}

type StatElement

type StatElement struct {
	Key     string
	Counter int64
}

type StatList

type StatList []StatElement

func (StatList) Len

func (p StatList) Len() int

func (StatList) Less

func (p StatList) Less(i, j int) bool

reverse order

func (StatList) Swap

func (p StatList) Swap(i, j int)

type StatsType

type StatsType struct {
	Statuses Statuses

	// contains the list of all done requests
	// 10 seconds of heavy stress doesn't eat much memory:
	// 10 seconds * 6000 prs = 60000 float64 = 60000 * 8 = 480000 < 0.5 Megabyte
	Times []float64
}

type Statuses

type Statuses map[string]int64

type StrDict

type StrDict map[string]interface{}

type StressTimes

type StressTimes struct {
	ElapsedTime      float64
	SpawningJobsTime float64
}

in seconds

func MakeStress

func MakeStress(jobFunc func(), rps float64, duration float64, requestCnt int) StressTimes

type TLSConfig

type TLSConfig struct {
	CA         string `toml:"ca"`
	Cert       string `toml:"cert"`
	Key        string `toml:"key"`
	SkipVerify bool   `toml:"skip_verify"`
	ServerName string `toml:"server_name"`
}

Jump to

Keyboard shortcuts

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