File tree Expand file tree Collapse file tree 5 files changed +26
-4
lines changed
TaskHub.Shared.Bootstraper
TaskHub.Shared.RateLimiter Expand file tree Collapse file tree 5 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 44 <ImplicitUsings >enable</ImplicitUsings >
55 <Nullable >enable</Nullable >
66 <IsPackable >true</IsPackable >
7- <Version >2.1.27 </Version >
7+ <Version >2.1.28 </Version >
88 <Authors >Andrey Serdyuk</Authors >
99 <Company >TaskHub</Company >
1010 <PackageTags >#TaskHub</PackageTags >
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ public async Task StartWith<TContext>(Action<HostOptions> action) where TContext
4141 builder . AddAuthorizationService ( ) ;
4242 builder . AddAppOpenTelemetry ( ) ;
4343 builder . AddAppRedis ( ) ;
44+ builder . AddAppVersioning ( ) ;
45+ builder . AddFixedRateLimiter ( ) ;
4446 _initAct ( builder ) ;
4547 } ) ;
4648
Original file line number Diff line number Diff line change 1+ using Microsoft . AspNetCore . Builder ;
2+ using System . Text ;
3+ using TaskHub . Shared . ConfigurationTools ;
4+ using TaskHub . Shared . RateLimiter ;
5+
6+ namespace TaskHub . Shared . Bootstraper . Settings ;
7+
8+ public static class AddRateLimiter
9+ {
10+ public static void AddFixedRateLimiter ( this WebApplicationBuilder builder ) => builder . Services . AddFixedRateLimiter ( options =>
11+ {
12+ var section = builder . Configuration . GetSection ( "RateLimiter" ) ;
13+ options . IsEnabled = section . GetBool ( "IsEnabled" ) ;
14+ options . AutoReplenishment = section . GetBool ( "AutoReplenishment" ) ;
15+ options . PermitLimit = section . GetInt ( "PermitLimit" ) ;
16+ options . QueueLimit = section . GetInt ( "QueueLimit" ) ;
17+ options . ProcessingOrder = section . GetString ( "ProcessingOrder" ) ;
18+ } ) ;
19+ }
Original file line number Diff line number Diff line change 1111 <ProjectReference Include =" ..\TaskHub.Shared.ConfigurationTools\TaskHub.Shared.ConfigurationTools.csproj" />
1212 <ProjectReference Include =" ..\TaskHub.Shared.Infrastructure.EfCore\TaskHub.Shared.Infrastructure.EfCore.csproj" />
1313 <ProjectReference Include =" ..\TaskHub.Shared.OpenTelemetry\TaskHub.Shared.OpenTelemetry.csproj" />
14+ <ProjectReference Include =" ..\TaskHub.Shared.RateLimiter\TaskHub.Shared.RateLimiter.csproj" />
1415 <ProjectReference Include =" ..\TaskHub.Shared.Redis\TaskHub.Shared.Redis.csproj" />
1516 <ProjectReference Include =" ..\TaskHub.Shared.Response\TaskHub.Shared.Response.csproj" />
1617 <ProjectReference Include =" ..\TaskHub.Shared.Swagger\TaskHub.Shared.Swagger.csproj" />
Original file line number Diff line number Diff line change @@ -10,12 +10,12 @@ public class FixedLimiterOptions
1010 public int PermitLimit { get ; set ; } = 0 ;
1111 public int QueueLimit { get ; set ; } = 0 ;
1212 public int Window { get ; set ; } = 0 ;
13- public int ProcessingOrder { get ; set ; } = 0 ;
13+ public string ProcessingOrder { get ; set ; } = string . Empty ;
1414
1515 public QueueProcessingOrder QueueProcessingOrder => ProcessingOrder switch
1616 {
17- 0 => QueueProcessingOrder . OldestFirst ,
18- 1 => QueueProcessingOrder . NewestFirst ,
17+ "OldestFirst" => QueueProcessingOrder . OldestFirst ,
18+ "NewestFirst" => QueueProcessingOrder . NewestFirst ,
1919 _ => QueueProcessingOrder . OldestFirst
2020 } ;
2121}
You can’t perform that action at this time.
0 commit comments