scenario

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientPool

func NewClientPool(initialCap, maxCap int, factory ClientFactoryMethod, close ClientCloseMethod) (*util.Pool[*http.Client], error)

NewClientPool returns a new pool based on buffered channels with an initial capacity and maximum capacity. Factory is used when initial capacity is greater than zero to fill the pool. A zero initialCap doesn't fill the Pool until a new Get() is called. During a Get(), If there is no new client available in the pool, a new client will be created via the Factory() method.

Types

type ClientCloseMethod

type ClientCloseMethod func(*http.Client)

type ClientFactoryMethod

type ClientFactoryMethod func() *http.Client

Factory is a function to create new connections.

type DurationSleep

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

DurationSleep is the implementation of the exact duration sleep feature

type RangeSleep

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

RangeSleep is the implementation of the range sleep feature

type ScenarioOpts

type ScenarioOpts struct {
	Debug                  bool
	IterationCount         int
	MaxConcurrentIterCount int
	EngineMode             string
}

type ScenarioService

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

ScenarioService encapsulates proxy/scenario/requester information and runs the scenario.

func NewScenarioService

func NewScenarioService() *ScenarioService

NewScenarioService is the constructor of the ScenarioService.

func (*ScenarioService) Do

func (s *ScenarioService) Do(proxy *url.URL, startTime time.Time) (
	response *types.ScenarioResult, err *types.RequestError)

Do executes the scenario for the given proxy. Returns "types.Response" filled by the requester of the given Proxy, injects the given startTime to the response Returns error only if types.Response.Err.Type is types.ErrorProxy or types.ErrorIntented

func (*ScenarioService) Done

func (s *ScenarioService) Done()

func (*ScenarioService) Init

func (s *ScenarioService) Init(ctx context.Context, scenario types.Scenario,
	proxies []*url.URL, opts ScenarioOpts) (err error)

Init initializes the ScenarioService.clients with the given types.Scenario and proxies. Passes the given ctx to the underlying requestor so we are able to control the life of each request.

type Sleeper

type Sleeper interface {
	// contains filtered or unexported methods
}

Sleeper is the interface for implementing different sleep strategies.

Jump to

Keyboard shortcuts

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