amocrm/tests/limiter/limiter_test.go

30 lines
478 B
Go
Raw Normal View History

2024-04-14 15:28:00 +00:00
package limiter
import (
"context"
"fmt"
2025-02-27 13:30:52 +00:00
"gitea.pena/SQuiz/amocrm/internal/workers/limiter"
2024-04-14 15:28:00 +00:00
"testing"
"time"
)
func Test_Limiter(t *testing.T) {
ctx := context.Background()
2024-04-22 07:49:46 +00:00
rateLimiter := limiter.NewRateLimiter(ctx, 6, 1500*time.Millisecond)
2024-04-14 15:28:00 +00:00
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)
}