From 266024f8021b36ab0f02a86750e1b84df6eae31b Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Fri, 19 Aug 2022 17:03:52 -1000 Subject: [PATCH] fix snippets in rate limiter code (#16) --- .../middleware/rate-limit/WebRateLimitAuth/Program.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fundamentals/middleware/rate-limit/WebRateLimitAuth/Program.cs b/fundamentals/middleware/rate-limit/WebRateLimitAuth/Program.cs index a91b1a8..b3d01e2 100644 --- a/fundamentals/middleware/rate-limit/WebRateLimitAuth/Program.cs +++ b/fundamentals/middleware/rate-limit/WebRateLimitAuth/Program.cs @@ -1,4 +1,4 @@ -#define FIRST // FIRST ADMIN FIXED SLIDING CONCUR TOKEN FIXED2 JWT +#define TOKEN // FIRST ADMIN FIXED SLIDING CONCUR TOKEN FIXED2 JWT #if NEVER #elif FIXED // @@ -109,10 +109,10 @@ app.MapGet("/", async () => }).RequireRateLimiting(concurrencyPolicy); app.Run(); -// +// #elif TOKEN // Quicktest 20 users, 20 seconds -> 8965 requests 2,250 errors -// +// using Microsoft.AspNetCore.RateLimiting; using System.Threading.RateLimiting; using WebRateLimitAuth.Models; @@ -131,7 +131,7 @@ app.UseRateLimiter(new RateLimiterOptions() new TokenBucketRateLimiterOptions(tokenLimit: myOptions.tokenLimit, queueProcessingOrder: QueueProcessingOrder.OldestFirst, queueLimit: myOptions.queueLimit, - replenishmentPeriod: TimeSpan.FromSeconds(2), + replenishmentPeriod: TimeSpan.FromSeconds(myOptions.replenishmentPeriod), tokensPerPeriod: myOptions.tokensPerPeriod, autoReplenishment: myOptions.autoReplenishment)));