MCPcopy
hub / github.com/tsenart/vegeta / NewAttacker

Function NewAttacker

lib/attack.go:70–100  ·  view source on GitHub ↗

NewAttacker returns a new Attacker with default options which are overridden by the optionally provided opts.

(opts ...func(*Attacker))

Source from the content-addressed store, hash-verified

68// NewAttacker returns a new Attacker with default options which are overridden
69// by the optionally provided opts.
70func NewAttacker(opts ...func(*Attacker)) *Attacker {
71 a := &Attacker{
72 stopch: make(chan struct{}),
73 stopOnce: sync.Once{},
74 workers: DefaultWorkers,
75 maxWorkers: DefaultMaxWorkers,
76 maxBody: DefaultMaxBody,
77 }
78
79 a.dialer = &net.Dialer{
80 LocalAddr: &net.TCPAddr{IP: DefaultLocalAddr.IP, Zone: DefaultLocalAddr.Zone},
81 KeepAlive: 30 * time.Second,
82 }
83
84 a.client = http.Client{
85 Timeout: DefaultTimeout,
86 Transport: &http.Transport{
87 Proxy: http.ProxyFromEnvironment,
88 DialContext: a.dialer.DialContext,
89 TLSClientConfig: DefaultTLSConfig,
90 MaxIdleConnsPerHost: DefaultConnections,
91 MaxConnsPerHost: DefaultMaxConnections,
92 },
93 }
94
95 for _, opt := range opts {
96 opt(a)
97 }
98
99 return a
100}
101
102// Workers returns a functional option which sets the initial number of workers
103// an Attacker uses to hit its targets. More workers may be spawned dynamically

Callers 15

TestAttackRateFunction · 0.85
TestAttackDurationFunction · 0.85
TestTLSConfigFunction · 0.85
TestRedirectsFunction · 0.85
TestNoFollowFunction · 0.85
TestTimeoutFunction · 0.85
TestLocalAddrFunction · 0.85
TestKeepAliveFunction · 0.85
TestSessionTicketsFunction · 0.85
TestConnectionsFunction · 0.85
TestStatusCodeErrorsFunction · 0.85
TestBadTargeterErrorFunction · 0.85

Calls

no outgoing calls

Tested by 15

TestAttackRateFunction · 0.68
TestAttackDurationFunction · 0.68
TestTLSConfigFunction · 0.68
TestRedirectsFunction · 0.68
TestNoFollowFunction · 0.68
TestTimeoutFunction · 0.68
TestLocalAddrFunction · 0.68
TestKeepAliveFunction · 0.68
TestSessionTicketsFunction · 0.68
TestConnectionsFunction · 0.68
TestStatusCodeErrorsFunction · 0.68
TestBadTargeterErrorFunction · 0.68