Fix broken syntax, incorrect parameter types, etc in examples

Pero 2015-04-23 13:27:36 -07:00
parent 653d145763
commit 336019ed2e

@ -8,8 +8,8 @@ For higher rates, prefer a token bucket rate limiter (search godoc.org for
```go
import "time"
ratePerSec := 10
throttle := time.Tick(1e9 / ratePerSec)
rate := time.Second / 10
throttle := time.Tick(rate)
for req := range requests {
<-throttle // rate limit our Service.Method RPCs
go client.Call("Service.Method", req, ...)
@ -20,15 +20,15 @@ To allow some bursts, add a buffer to the throttle:
```go
import "time"
ratePerSec := 10
rate := time.Second / 10
burstLimit := 100
tick := time.NewTicker(1e9 / ratePerSec)
tick := time.NewTicker(rate)
defer tick.Stop()
throttle := make(chan time.Time, burstLimit)
go func() {
for t := range tick {
for t := range tick.C {
select {
case: throttle <- t
case throttle <- t:
default:
}
} // exits after tick.Stop()