-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RateLimitManager gracefully handles individual RateLimiters being clo…
…sed already.
- Loading branch information
Josh Branham
committed
Mar 1, 2024
1 parent
d96ff41
commit 15c87d8
Showing
2 changed files
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
package tcpproxy | ||
|
||
import ( | ||
"log/slog" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewRateLimitManager(t *testing.T) { | ||
rlm := NewRateLimitManager(10, 1*time.Millisecond) | ||
rlm := NewRateLimitManager(10, 1*time.Millisecond, slog.Default()) | ||
|
||
user1 := rlm.RateLimiterFor("user1") | ||
assert.Equal(t, user1, rlm.RateLimiterFor("user1")) | ||
|
||
// Ensure we clean up goroutines for the manager and any child RateLimiters | ||
assert.NoError(t, rlm.Close()) | ||
rlm.Close() | ||
} |