From 9d9259214d9c3ce01758528ddcde508d7d895783 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Feb 2026 22:10:12 -0600 Subject: add base delay --- src/slskd/Common/Retry.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/Retry.cs b/src/slskd/Common/Retry.cs index f57b59d8..eff88659 100644 --- a/src/slskd/Common/Retry.cs +++ b/src/slskd/Common/Retry.cs @@ -34,6 +34,7 @@ namespace slskd /// A function returning a value indicating whether the last Exception is retryable. /// An action to execute on failure. /// The maximum number of retry attempts. + /// The base delay in milliseconds. /// The maximum delay in milliseconds. /// The token to monitor for cancellation requests. /// The execution context. @@ -42,6 +43,7 @@ namespace slskd Func isRetryable = null, Action onFailure = null, int maxAttempts = 3, + int baseDelayInMilliseconds = 1000, int maxDelayInMilliseconds = int.MaxValue, CancellationToken cancellationToken = default) { @@ -49,7 +51,7 @@ namespace slskd { await task(); return Task.FromResult(null); - }, isRetryable, onFailure, maxAttempts, maxDelayInMilliseconds, cancellationToken); + }, isRetryable, onFailure, maxAttempts, baseDelayInMilliseconds, maxDelayInMilliseconds, cancellationToken); } /// @@ -59,6 +61,7 @@ namespace slskd /// A function returning a value indicating whether the last Exception is retryable. /// An action to execute on failure. /// The maximum number of retry attempts. + /// The base delay in milliseconds. /// The maximum delay in milliseconds. /// The token to monitor for cancellation requests. /// The Type of the logic return value. @@ -68,6 +71,7 @@ namespace slskd Func isRetryable = null, Action onFailure = null, int maxAttempts = 3, + int baseDelayInMilliseconds = 1000, int maxDelayInMilliseconds = int.MaxValue, CancellationToken cancellationToken = default) { @@ -87,7 +91,7 @@ namespace slskd { if (attempts > 0) { - var (delay, jitter) = Compute.ExponentialBackoffDelay(attempts, maxDelayInMilliseconds); + var (delay, jitter) = Compute.ExponentialBackoffDelay(attempts, baseDelayInMilliseconds, maxDelayInMilliseconds); await Task.Delay(delay + jitter, cancellationToken); } -- cgit v1.2.3