Skip to content

Commit

Permalink
apps/to_nsq: fix --rate divide by zero bug
Browse files Browse the repository at this point in the history
  • Loading branch information
adamweiner committed Mar 24, 2017
1 parent 62c3858 commit eaeb38c
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 eaeb38c

Please sign in to comment.