Make lowercase arg

This commit is contained in:
Abhishek Pandey 2023-11-08 21:38:21 -08:00
parent 59c0e7d6d3
commit 4df81e7fd7
3 changed files with 9 additions and 9 deletions

View File

@ -4,6 +4,6 @@ import "context"
type Limiter interface { type Limiter interface {
Wait(ctx context.Context) error Wait(ctx context.Context) error
WaitN(ctx context.Context, N int) error WaitN(ctx context.Context, n int) error
Shutdown() Shutdown()
} }

View File

@ -91,8 +91,8 @@ func (s *slidingWindow) Wait(ctx context.Context) error {
// Wait blocks a request until N tokens are available or the context gets // Wait blocks a request until N tokens are available or the context gets
// cancelled. // cancelled.
func (s *slidingWindow) WaitN(ctx context.Context, N int) error { func (s *slidingWindow) WaitN(ctx context.Context, n int) error {
for i := 0; i < N; i++ { for i := 0; i < n; i++ {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return clues.Stack(ctx.Err()) return clues.Stack(ctx.Err())

View File

@ -89,23 +89,23 @@ func (suite *SlidingWindowUnitTestSuite) TestWaitSliding() {
slideInterval time.Duration slideInterval time.Duration
capacity int capacity int
numRequests int numRequests int
N int n int
}{ }{
{ {
Name: "Request 1 token", Name: "Request 1 token each",
windowSize: 1 * time.Second, windowSize: 1 * time.Second,
slideInterval: 10 * time.Millisecond, slideInterval: 10 * time.Millisecond,
capacity: 100, capacity: 100,
numRequests: 200, numRequests: 200,
N: 1, n: 1,
}, },
{ {
Name: "Request 5 tokens", Name: "Request 5 tokens each",
windowSize: 1 * time.Second, windowSize: 1 * time.Second,
slideInterval: 10 * time.Millisecond, slideInterval: 10 * time.Millisecond,
capacity: 100, capacity: 100,
numRequests: 100, numRequests: 100,
N: 5, n: 5,
}, },
} }
@ -136,7 +136,7 @@ func (suite *SlidingWindowUnitTestSuite) TestWaitSliding() {
// of the 2 windows. Rest of the intervals will be empty. // of the 2 windows. Rest of the intervals will be empty.
time.Sleep(time.Duration(rand.Intn(1500)) * time.Millisecond) time.Sleep(time.Duration(rand.Intn(1500)) * time.Millisecond)
err := s.WaitN(ctx, test.N) err := s.WaitN(ctx, test.n)
require.NoError(t, err) require.NoError(t, err)
}() }()
} }