fix snippets in rate limiter code (#16)

pull/17/head
Rick Anderson 2022-08-19 17:03:52 -10:00 committed by GitHub
parent c8f1948cbf
commit 266024f802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -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
// <snippet_fixed>
@ -109,10 +109,10 @@ app.MapGet("/", async () =>
}).RequireRateLimiting(concurrencyPolicy);
app.Run();
// </snippet_token>
// </snippet_concur>
#elif TOKEN
// Quicktest 20 users, 20 seconds -> 8965 requests 2,250 errors
// <snippet_concur>
// <snippet_token>
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)));