From bee8ec24f32a7c0121afd0f209a9f02f89c277b6 Mon Sep 17 00:00:00 2001 From: Toni Leitold Date: Fri, 6 Oct 2023 10:38:16 +0200 Subject: [PATCH 1/2] fix: Golden EDI specific fix for rate limit based on that we have two data centers (The Fortnox limit seems to be 25 requests on 5 seconds so we are using half of that) --- FortnoxSDK/Connectors/Base/RateLimiter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FortnoxSDK/Connectors/Base/RateLimiter.cs b/FortnoxSDK/Connectors/Base/RateLimiter.cs index 78c9018b..02507eac 100644 --- a/FortnoxSDK/Connectors/Base/RateLimiter.cs +++ b/FortnoxSDK/Connectors/Base/RateLimiter.cs @@ -11,8 +11,8 @@ namespace Fortnox.SDK.Connectors.Base; /// internal class RateLimiter { - private const int MaxCount = 4; - private static readonly TimeSpan Period = TimeSpan.FromSeconds(1); + private const int MaxCount = 12; + private static readonly TimeSpan Period = TimeSpan.FromSeconds(5); private static readonly Dictionary RateLimiters = new(); From ed8a9e5894c4497e187284981ec37b81400aaab8 Mon Sep 17 00:00:00 2001 From: Toni Leitold Date: Wed, 11 Oct 2023 11:22:24 +0200 Subject: [PATCH 2/2] task: GEDI RateLimiter modifications --- FortnoxSDK/Connectors/Base/BaseClient.cs | 8 ++++++-- FortnoxSDK/Connectors/Base/RateLimiter.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FortnoxSDK/Connectors/Base/BaseClient.cs b/FortnoxSDK/Connectors/Base/BaseClient.cs index 27e91306..f05914a8 100644 --- a/FortnoxSDK/Connectors/Base/BaseClient.cs +++ b/FortnoxSDK/Connectors/Base/BaseClient.cs @@ -7,15 +7,19 @@ namespace Fortnox.SDK.Connectors.Base; internal abstract class BaseClient { public ErrorHandler ErrorHandler { get; set; } - public RateLimiter RateLimiter { get; set; } + public static RateLimiter RateLimiter { get; set; } public HttpClient HttpClient { get; set; } public bool UseRateLimiter { get; set; } = true; public FortnoxAuthorization Authorization { get; set; } - protected BaseClient() + static BaseClient() { RateLimiter = new RateLimiter(); + } + + protected BaseClient() + { ErrorHandler = new ErrorHandler(); } diff --git a/FortnoxSDK/Connectors/Base/RateLimiter.cs b/FortnoxSDK/Connectors/Base/RateLimiter.cs index 02507eac..b44dccde 100644 --- a/FortnoxSDK/Connectors/Base/RateLimiter.cs +++ b/FortnoxSDK/Connectors/Base/RateLimiter.cs @@ -11,7 +11,7 @@ namespace Fortnox.SDK.Connectors.Base; /// internal class RateLimiter { - private const int MaxCount = 12; + private const int MaxCount = 10; private static readonly TimeSpan Period = TimeSpan.FromSeconds(5); private static readonly Dictionary RateLimiters = new();