fix snippets in rate limiter code (#16)
parent
c8f1948cbf
commit
266024f802
|
@ -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
|
#if NEVER
|
||||||
#elif FIXED
|
#elif FIXED
|
||||||
// <snippet_fixed>
|
// <snippet_fixed>
|
||||||
|
@ -109,10 +109,10 @@ app.MapGet("/", async () =>
|
||||||
}).RequireRateLimiting(concurrencyPolicy);
|
}).RequireRateLimiting(concurrencyPolicy);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
// </snippet_token>
|
// </snippet_concur>
|
||||||
#elif TOKEN
|
#elif TOKEN
|
||||||
// Quicktest 20 users, 20 seconds -> 8965 requests 2,250 errors
|
// Quicktest 20 users, 20 seconds -> 8965 requests 2,250 errors
|
||||||
// <snippet_concur>
|
// <snippet_token>
|
||||||
using Microsoft.AspNetCore.RateLimiting;
|
using Microsoft.AspNetCore.RateLimiting;
|
||||||
using System.Threading.RateLimiting;
|
using System.Threading.RateLimiting;
|
||||||
using WebRateLimitAuth.Models;
|
using WebRateLimitAuth.Models;
|
||||||
|
@ -131,7 +131,7 @@ app.UseRateLimiter(new RateLimiterOptions()
|
||||||
new TokenBucketRateLimiterOptions(tokenLimit: myOptions.tokenLimit,
|
new TokenBucketRateLimiterOptions(tokenLimit: myOptions.tokenLimit,
|
||||||
queueProcessingOrder: QueueProcessingOrder.OldestFirst,
|
queueProcessingOrder: QueueProcessingOrder.OldestFirst,
|
||||||
queueLimit: myOptions.queueLimit,
|
queueLimit: myOptions.queueLimit,
|
||||||
replenishmentPeriod: TimeSpan.FromSeconds(2),
|
replenishmentPeriod: TimeSpan.FromSeconds(myOptions.replenishmentPeriod),
|
||||||
tokensPerPeriod: myOptions.tokensPerPeriod,
|
tokensPerPeriod: myOptions.tokensPerPeriod,
|
||||||
autoReplenishment: myOptions.autoReplenishment)));
|
autoReplenishment: myOptions.autoReplenishment)));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue