Function
processAttack
(
atk *vegeta.Attacker,
res <-chan *vegeta.Result,
enc vegeta.Encoder,
sig <-chan os.Signal,
pm *prom.Metrics,
)
Source from the content-addressed store, hash-verified
| 233 | } |
| 234 | |
| 235 | func processAttack( |
| 236 | atk *vegeta.Attacker, |
| 237 | res <-chan *vegeta.Result, |
| 238 | enc vegeta.Encoder, |
| 239 | sig <-chan os.Signal, |
| 240 | pm *prom.Metrics, |
| 241 | ) error { |
| 242 | for { |
| 243 | select { |
| 244 | case <-sig: |
| 245 | if stopSent := atk.Stop(); !stopSent { |
| 246 | // Exit immediately on second signal. |
| 247 | return nil |
| 248 | } |
| 249 | case r, ok := <-res: |
| 250 | if !ok { |
| 251 | return nil |
| 252 | } |
| 253 | |
| 254 | if pm != nil { |
| 255 | pm.Observe(r) |
| 256 | } |
| 257 | |
| 258 | if err := enc.Encode(r); err != nil { |
| 259 | return err |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // tlsConfig builds a *tls.Config from the given options. |
| 266 | func tlsConfig(insecure bool, certf, keyf string, rootCerts []string) (*tls.Config, error) { |