func (t *tokenBucketRateLimiter) Accept() {
	now := t.clock.Now()
	t.clock.Sleep(t.limiter.ReserveN(now, 1).DelayFrom(now))
}
Accept will block until a token becomes available
package flowcontrol
import (
	"sync"
	"time"
	"golang.org/x/time/rate"
)
type RateLimiter interface {
	TryAccept() bool
	Accept()
	Stop()
	QPS() float32
}
type tokenBucketRateLimiter struct {
	limiter *rate.Limiter
	clock   Clock
	qps     float32
}
func NewTokenBucketRateLimiter(qps float32, burst int) RateLimiter {
	limiter := rate.NewLimiter(rate.Limit(qps), burst)
	return newTokenBucketRateLimiter(limiter, realClock{}, qps)
}
type Clock interface {
	Now() time.Time
	Sleep(time.Duration)
}
type realClock struct{}
func (realClock) Now() time.Time {
	return time.Now()
}
func (realClock) Sleep(d time.Duration) {
	time.Sleep(d)
}
func NewTokenBucketRateLimiterWithClock(qps float32, burst int, c Clock) RateLimiter {
	limiter := rate.NewLimiter(rate.Limit(qps), burst)
	return newTokenBucketRateLimiter(limiter, c, qps)
}
func newTokenBucketRateLimiter(limiter *rate.Limiter, c Clock, qps float32) RateLimiter {
	return &tokenBucketRateLimiter{
		limiter: limiter,
		clock:   c,
		qps:     qps,
	}
}
func (t *tokenBucketRateLimiter) TryAccept() bool {
	return t.limiter.AllowN(t.clock.Now(), 1)
}