Skip to content

Commit

Permalink
limit connections to concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
olix0r committed May 23, 2016
1 parent 10e5f45 commit bb4f6b4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ func newClient(
compress bool,
https bool,
reuse bool,
maxConn uint,
) *http.Client {
tr := http.Transport{
DisableCompression: !compress,
DisableKeepAlives: !reuse,
DisableCompression: !compress,
DisableKeepAlives: !reuse,
MaxIdleConnsPerHost: int(maxConn),
}
if https {
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
Expand Down Expand Up @@ -116,7 +118,7 @@ func main() {
timeToWait := time.Millisecond * time.Duration(1000 / *qps)

doTLS := dstURL.Scheme == "https"
client := newClient(*compress, doTLS, *reuse)
client := newClient(*compress, doTLS, *reuse, *concurrency)

for i := uint(0); i < *concurrency; i++ {
ticker := time.NewTicker(timeToWait)
Expand Down

0 comments on commit bb4f6b4

Please sign in to comment.