uber-go / ratelimit

A Go blocking leaky-bucket rate limit implementation
MIT License
4.32k stars 300 forks source link

The "slack" option doesn't make effect when use newAtomicInt64Based version rate limit #122

Open nemohan opened 10 months ago

nemohan commented 10 months ago

Use following test code: func TestSlack2(t *testing.T) { rl := New(1, WithSlack(2)) // per second, some slack. rl.Take() // Initialize. time.Sleep(time.Second * 4) for i := 0; i < 100; i++ { rl.Take() fmt.Printf("%d\n", time.Now().Unix()) } } I got those output: 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 1702546953 ....