diff --git a/Infrastructure/RateLimiter.cs b/Infrastructure/RateLimiter.cs index faaa214..403acd6 100644 --- a/Infrastructure/RateLimiter.cs +++ b/Infrastructure/RateLimiter.cs @@ -13,7 +13,7 @@ _maxRequests = maxRequests; _interval = interval; var now = DateTime.Now; - _windowStart = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute - (now.Minute % interval.Minutes), 0); + _windowStart = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0); _requestCount = 0; } diff --git a/Presentation/Program.cs b/Presentation/Program.cs index 6bbb86e..eaf2776 100644 --- a/Presentation/Program.cs +++ b/Presentation/Program.cs @@ -29,7 +29,7 @@ class Program ServerCertificateCustomValidationCallback = (HttpRequestMessage req, X509Certificate2? cert, X509Chain? chain, SslPolicyErrors errors) => true }); - var rateLimiter = new RateLimiter(400, TimeSpan.FromMinutes(1)); + var rateLimiter = new RateLimiter(12, TimeSpan.FromSeconds(1)); var useCase = new ProcessarMedicoesUseCase(postgresRepo, accessRepo, httpClient, rateLimiter); await useCase.ExecuteAsync(dataIni, dataFim, caminhoLog, CancellationToken.None);