httpscenario

package
v0.5.17 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmptyTag = "__EMPTY__"
)

Variables

This section is empty.

Functions

func Import

func Import(fs afero.Fs)

func PreResolveTargetAddr

func PreResolveTargetAddr(clientConf *phttp.ClientConfig, target string) (string, error)

DNS resolve optimisation. When DNSCache turned off - do nothing extra, host will be resolved on every shoot. When using resolved target, don't use DNS caching logic - it is useless. If we can resolve accessible target addr - use it as target, not use caching. Otherwise just use DNS cache - we should not fail shooting, we should try to connect on every shoot. DNS cache will save resolved addr after first successful connect.

func WrapGun

func WrapGun(g Gun) core.Gun

Types

type Ammo

type Ammo interface {
	Steps() []Step
	ID() uint64
	Sources() VariableStorage
	Name() string
	GetMinWaitingTime() time.Duration
}

type BaseGun

type BaseGun struct {
	DebugLog   bool // Automaticaly set in Bind if Log accepts debug messages.
	Config     phttp.BaseGunConfig
	Connect    func(ctx context.Context) error // Optional hook.
	OnClose    func() error                    // Optional. Called on Close().
	Aggregator netsample.Aggregator            // Lazy set via BindResultTo.
	AnswLog    *zap.Logger
	core.GunDeps
	// contains filtered or unexported fields
}

func NewClientGun

func NewClientGun(client Client, conf phttp.ClientGunConfig, answLog *zap.Logger, targetResolved string) *BaseGun

func NewHTTP2Gun

func NewHTTP2Gun(conf phttp.HTTP2GunConfig, answLog *zap.Logger, targetResolved string) (*BaseGun, error)

NewHTTP2Gun return simple HTTP/2 gun that can shoot sequentially through one connection.

func NewHTTPGun

func NewHTTPGun(conf phttp.HTTPGunConfig, answLog *zap.Logger, targetResolved string) *BaseGun

func (*BaseGun) Bind

func (g *BaseGun) Bind(aggregator netsample.Aggregator, deps core.GunDeps) error

func (*BaseGun) Close

func (g *BaseGun) Close() error

func (*BaseGun) Do

func (g *BaseGun) Do(req *http.Request) (*http.Response, error)

func (*BaseGun) Shoot

func (g *BaseGun) Shoot(ammo Ammo)

Shoot is thread safe iff Do and Connect hooks are thread safe.

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
	CloseIdleConnections() // We should close idle conns after gun close.
}

type Gun

type Gun interface {
	Shoot(ammo Ammo)
	Bind(sample netsample.Aggregator, deps core.GunDeps) error
}

type Postprocessor

type Postprocessor interface {
	Process(resp *http.Response, body io.Reader) (map[string]any, error)
}

type Preprocessor

type Preprocessor interface {
	// Process is called before request is sent
	// templateVars - variables from template. Can be modified
	// sourceVars - variables from sources. Must NOT be modified
	Process(templateVars map[string]any) (map[string]any, error)
}

type RequestParts

type RequestParts struct {
	URL     string
	Method  string
	Body    []byte
	Headers map[string]string
}

type Step

type Step interface {
	GetName() string
	GetURL() string
	GetMethod() string
	GetBody() []byte
	GetHeaders() map[string]string
	GetTag() string
	GetTemplater() Templater
	GetPostProcessors() []Postprocessor
	Preprocessor() Preprocessor
	GetSleep() time.Duration
}

type Templater

type Templater interface {
	Apply(request *RequestParts, variables map[string]any, scenarioName, stepName string) error
}

type VariableStorage

type VariableStorage interface {
	Variables() map[string]any
}

Jump to

Keyboard shortcuts

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