diff --git a/Shoko.Server/Providers/AniDB/AniDBRateLimiter.cs b/Shoko.Server/Providers/AniDB/AniDBRateLimiter.cs index f07efc12e..2cb103cbe 100644 --- a/Shoko.Server/Providers/AniDB/AniDBRateLimiter.cs +++ b/Shoko.Server/Providers/AniDB/AniDBRateLimiter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Threading; using Microsoft.Extensions.Logging; @@ -22,11 +22,11 @@ public abstract class AniDBRateLimiter // An extended amount of time is not defined. Use common sense. protected abstract int LongDelay { get; init; } - // Switch to longer delay after 1 hour - protected abstract long shortPeriod { get; init; } + // Switch to longer delay after a short period + protected abstract long ShortPeriod { get; init; } - // Switch to shorter delay after 30 minutes of inactivity - protected abstract long resetPeriod { get; init; } + // Switch to shorter delay after inactivity + protected abstract long ResetPeriod { get; init; } protected AniDBRateLimiter(ILogger logger) { @@ -51,8 +51,8 @@ public T EnsureRate(Func action) if (!entered) throw new SynchronizationLockException(); var delay = _requestWatch.ElapsedMilliseconds; - if (delay > resetPeriod) ResetRate(); - var currentDelay = _activeTimeWatch.ElapsedMilliseconds > shortPeriod ? LongDelay : ShortDelay; + if (delay > ResetPeriod) ResetRate(); + var currentDelay = _activeTimeWatch.ElapsedMilliseconds > ShortPeriod ? LongDelay : ShortDelay; if (delay > currentDelay) { diff --git a/Shoko.Server/Providers/AniDB/HTTP/HttpRateLimiter.cs b/Shoko.Server/Providers/AniDB/HTTP/HttpRateLimiter.cs index 7c3c41398..6d17ff5f9 100644 --- a/Shoko.Server/Providers/AniDB/HTTP/HttpRateLimiter.cs +++ b/Shoko.Server/Providers/AniDB/HTTP/HttpRateLimiter.cs @@ -4,10 +4,10 @@ namespace Shoko.Server.Providers.AniDB.HTTP; public class HttpRateLimiter : AniDBRateLimiter { - protected override int ShortDelay { get; init; } = 2000; - protected override int LongDelay { get; init; } = 4000; - protected override long shortPeriod { get; init; } = 1000000; - protected override long resetPeriod { get; init; } = 1800000; + protected override int ShortDelay { get; init; } = 2_000; + protected override int LongDelay { get; init; } = 30_000; + protected override long ShortPeriod { get; init; } = 10_000; + protected override long ResetPeriod { get; init; } = 120_000; public HttpRateLimiter(ILogger logger) : base(logger) { diff --git a/Shoko.Server/Providers/AniDB/UDP/UDPRateLimiter.cs b/Shoko.Server/Providers/AniDB/UDP/UDPRateLimiter.cs index e4993d760..6ad4d6ef4 100644 --- a/Shoko.Server/Providers/AniDB/UDP/UDPRateLimiter.cs +++ b/Shoko.Server/Providers/AniDB/UDP/UDPRateLimiter.cs @@ -4,10 +4,10 @@ namespace Shoko.Server.Providers.AniDB.UDP; public class UDPRateLimiter : AniDBRateLimiter { - protected override int ShortDelay { get; init; } = 2000; - protected override int LongDelay { get; init; } = 4000; - protected override long shortPeriod { get; init; } = 3600000; - protected override long resetPeriod { get; init; } = 1800000; + protected override int ShortDelay { get; init; } = 2_000; + protected override int LongDelay { get; init; } = 6_000; + protected override long ShortPeriod { get; init; } = 10_000; + protected override long ResetPeriod { get; init; } = 120_000; public UDPRateLimiter(ILogger logger) : base(logger) {