Decouple Reporters from Attack function
This changeset breaks the API of Attack in order to decouple Reporters and the Attack function. Attack now returns a slice with non-deterministic order of Results which one can use on the calling code with or without Reporters, hence making it much more useful on a library usage setting. These developments could be of interest to issue #11 which was closed in the past.
This commit is contained in:
5
main.go
5
main.go
@@ -94,9 +94,10 @@ func run(rate uint64, duration time.Duration, targetsf, ordering, reporter, outp
|
||||
}
|
||||
|
||||
log.Printf("Vegeta is attacking %d targets in %s order for %s...\n", len(targets), ordering, duration)
|
||||
vegeta.Attack(targets, rate, duration, rep)
|
||||
for _, result := range vegeta.Attack(targets, rate, duration) {
|
||||
rep.Add(&result)
|
||||
}
|
||||
log.Println("Done!")
|
||||
|
||||
log.Printf("Writing report to '%s'...", output)
|
||||
if err = rep.Report(out); err != nil {
|
||||
return fmt.Errorf(errReportingPrefix+"%s", err)
|
||||
|
||||
Reference in New Issue
Block a user