Skip to content

Commit

Permalink
Merge pull request #867 from adamweiner/to_nsq_divide_by_zero_866
Browse files Browse the repository at this point in the history
apps/to_nsq: fix --rate divide by zero bug
  • Loading branch information
jehiah authored Mar 24, 2017
2 parents 62c3858 + eaeb38c commit 8ad2491
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/to_nsq/to_nsq.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ func main() {

throttleEnabled := *rate >= 1
balance := int64(1)
interval := time.Second / time.Duration(*rate)
// avoid divide by 0 if !throttleEnabled
var interval time.Duration
if throttleEnabled {
interval = time.Second / time.Duration(*rate)
}
go func() {
if !throttleEnabled {
return
Expand Down

0 comments on commit 8ad2491

Please sign in to comment.