From ca229782047969a3f47309bbb2317e29b2c058e7 Mon Sep 17 00:00:00 2001 From: peter-csala <57183693+peter-csala@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:22:22 +0100 Subject: [PATCH] Fix sliding window rate limiter examples (#2437) Fix samples that throw an exception. --- README.md | 1 + docs/migration-v8.md | 2 ++ docs/strategies/rate-limiter.md | 1 + src/Polly.RateLimiting/README.md | 1 + src/Snippets/Docs/Migration.RateLimiter.cs | 2 ++ src/Snippets/Docs/RateLimiter.cs | 1 + 6 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 54f4934abf2..276068104d7 100644 --- a/README.md +++ b/README.md @@ -453,6 +453,7 @@ new ResiliencePipelineBuilder() new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1) })); ``` diff --git a/docs/migration-v8.md b/docs/migration-v8.md index 304497f688c..9858608ead5 100644 --- a/docs/migration-v8.md +++ b/docs/migration-v8.md @@ -468,6 +468,7 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddRateLimiter(new SlidingWindowRateLimiter(new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1), })) .Build(); @@ -479,6 +480,7 @@ ResiliencePipeline pipelineT = new ResiliencePipelineBuilde .AddRateLimiter(new SlidingWindowRateLimiter(new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1), })) .Build(); diff --git a/docs/strategies/rate-limiter.md b/docs/strategies/rate-limiter.md index 8781dcf9313..a1eb1062b51 100644 --- a/docs/strategies/rate-limiter.md +++ b/docs/strategies/rate-limiter.md @@ -41,6 +41,7 @@ new ResiliencePipelineBuilder() new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1) })); ``` diff --git a/src/Polly.RateLimiting/README.md b/src/Polly.RateLimiting/README.md index 986a86e76ee..aa355d4f1ed 100644 --- a/src/Polly.RateLimiting/README.md +++ b/src/Polly.RateLimiting/README.md @@ -27,6 +27,7 @@ new ResiliencePipelineBuilder() new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1) })); ``` diff --git a/src/Snippets/Docs/Migration.RateLimiter.cs b/src/Snippets/Docs/Migration.RateLimiter.cs index 8767fa66dfd..33d130a7087 100644 --- a/src/Snippets/Docs/Migration.RateLimiter.cs +++ b/src/Snippets/Docs/Migration.RateLimiter.cs @@ -44,6 +44,7 @@ public static void RateLimiter_V8() .AddRateLimiter(new SlidingWindowRateLimiter(new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1), })) .Build(); @@ -55,6 +56,7 @@ public static void RateLimiter_V8() .AddRateLimiter(new SlidingWindowRateLimiter(new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1), })) .Build(); diff --git a/src/Snippets/Docs/RateLimiter.cs b/src/Snippets/Docs/RateLimiter.cs index 7a5fe55ccf5..89472da9ef5 100644 --- a/src/Snippets/Docs/RateLimiter.cs +++ b/src/Snippets/Docs/RateLimiter.cs @@ -25,6 +25,7 @@ public static void Usage() new SlidingWindowRateLimiterOptions { PermitLimit = 100, + SegmentsPerWindow = 4, Window = TimeSpan.FromMinutes(1) }));