amocrm/tests/limiter/limiter_test.go

30 lines
452 B
Go
Raw Normal View History

2024-04-14 15:28:00 +00:00
package limiter
import (
"amocrm/pkg/amoClient"
"context"
"fmt"
"testing"
"time"
)
func Test_Limiter(t *testing.T) {
ctx := context.Background()
rateLimiter := amoClient.NewRateLimiter(ctx, 6, 1500*time.Millisecond)
go func() {
count := 1
for {
if rateLimiter.Check() {
fmt.Println("GO", count)
count++
continue
}
fmt.Println("SLEEP")
time.Sleep(1500 * time.Millisecond)
}
}()
time.Sleep(20 * time.Second)
}