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 {
Wait(ctx context.Context) error
WaitN(ctx context.Context, N int) error
WaitN(ctx context.Context, n int) error
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
// cancelled.
func (s *slidingWindow) WaitN(ctx context.Context, N int) error {
for i := 0; i < N; i++ {
func (s *slidingWindow) WaitN(ctx context.Context, n int) error {
for i := 0; i < n; i++ {
select {
case <-ctx.Done():
return clues.Stack(ctx.Err())

View File

@ -89,23 +89,23 @@ func (suite *SlidingWindowUnitTestSuite) TestWaitSliding() {
slideInterval time.Duration
capacity int
numRequests int
N int
n int
}{
{
Name: "Request 1 token",
Name: "Request 1 token each",
windowSize: 1 * time.Second,
slideInterval: 10 * time.Millisecond,
capacity: 100,
numRequests: 200,
N: 1,
n: 1,
},
{
Name: "Request 5 tokens",
Name: "Request 5 tokens each",
windowSize: 1 * time.Second,
slideInterval: 10 * time.Millisecond,
capacity: 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.
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)
}()
}