diff --git a/v2/internal/runner/runner.go b/v2/internal/runner/runner.go index b8d7beaa6..6543e9111 100644 --- a/v2/internal/runner/runner.go +++ b/v2/internal/runner/runner.go @@ -242,9 +242,9 @@ func New(options *types.Options) (*Runner, error) { } if options.RateLimitMinute > 0 { - runner.ratelimiter = ratelimit.New(context.Background(), options.RateLimitMinute, time.Minute) + runner.ratelimiter = ratelimit.New(context.Background(), int64(options.RateLimitMinute), time.Minute) } else if options.RateLimit > 0 { - runner.ratelimiter = ratelimit.New(context.Background(), options.RateLimit, time.Second) + runner.ratelimiter = ratelimit.New(context.Background(), int64(options.RateLimit), time.Second) } else { runner.ratelimiter = ratelimit.NewUnlimited(context.Background()) } diff --git a/v2/pkg/testutils/testutils.go b/v2/pkg/testutils/testutils.go index 16fd124ff..09024b288 100644 --- a/v2/pkg/testutils/testutils.go +++ b/v2/pkg/testutils/testutils.go @@ -89,7 +89,7 @@ func NewMockExecuterOptions(options *types.Options, info *TemplateInfo) *protoco IssuesClient: nil, Browser: nil, Catalog: disk.NewCatalog(options.TemplatesDirectory), - RateLimiter: ratelimit.New(context.Background(), options.RateLimit, time.Second), + RateLimiter: ratelimit.New(context.Background(), int64(options.RateLimit), time.Second), } return executerOpts } diff --git a/v2/pkg/utils/ratelimit/ratelimit.go b/v2/pkg/utils/ratelimit/ratelimit.go index 9bce0be35..9b789bc99 100644 --- a/v2/pkg/utils/ratelimit/ratelimit.go +++ b/v2/pkg/utils/ratelimit/ratelimit.go @@ -8,8 +8,8 @@ import ( // Limiter allows a burst of request during the defined duration type Limiter struct { - maxCount int - count int + maxCount int64 + count int64 ticker *time.Ticker tokens chan struct{} ctx context.Context @@ -40,7 +40,7 @@ func (rateLimiter *Limiter) Take() { } // New creates a new limiter instance with the tokens amount and the interval -func New(ctx context.Context, max int, duration time.Duration) *Limiter { +func New(ctx context.Context, max int64, duration time.Duration) *Limiter { limiter := &Limiter{ maxCount: max, count: max,