Skip to content

Commit

Permalink
Fix concurrency bug (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Bond authored and symm committed Jun 30, 2017
1 parent eae22d7 commit 2c1308d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions vape.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ func NewVape(client HTTPClient, baseURL *url.URL, resCh chan CheckResult, errCh
// Process takes a list of URIs and concurrently performs a smoke test on each.
func (v Vape) Process(statusCodeChecks StatusCodeChecks) {
// TODO: limit the numer of concurrent requests so we don't DoS the server
for _, check := range statusCodeChecks {
go func(check StatusCodeCheck) {
result, err := v.performCheck(check)
if err != nil {
v.errCh <- err
return
}
v.resCh <- result
}(check)
}
go func() {
for _, check := range statusCodeChecks {
go func(check StatusCodeCheck) {
result, err := v.performCheck(check)
if err != nil {
v.errCh <- err
return
}
v.resCh <- result
}(check)
}
}()
}

// performCheck checks the status code of a HTTP request of a given URI.
Expand Down

0 comments on commit 2c1308d

Please sign in to comment.