csfrancis/gonan — pull request #1 by aybabtme (2014-01-22 00:00:01+00:00)
Title: Reuse goroutines

* Reuse goroutines instead of spawning new ones at each request.
* Some refactor to follow Go idioms (declarations).
* Create a `gonanClient` type wrapping `http.Client`, to avoid type casts of `gonanRoundTripper`.
* Close channels.
* Limit the GoogleFlow to use 100 concurrent workers, as OS X doesn't allow 500 connections by default (inconvenient to try out the tool).
* Change test, `Run.Cancel` returns an error on the `errchan` of `ExecuteAsync()`, but doesn't create an error in the NumSuccess/NumError fields. The logic behind that is that a call to `Cancel` is not a connection error, thus shouldn't be counted as one. Unless I missunderstood something.

Other things I've noticed but haven't fixed:
* There's a race condition on `Result.EndTime`.
* Error messages in Go usually don't include filename/line number, but a message to give context. They then bubble up the call stack with calls to `fmt.Errorf("happened in this context: %v", err)`, which make the errors traceable.
* The count of requests sent is double the real count (that's `gonanRoundTripper`'s fault). See:

```
$ go run examples/gonan-google/main.go
Executed run in 6.639340435s, err=
10000 requests sent (5000 success, 0 errors).
```