From 572aa0502b325fc9657eef774f034a43a7078e1a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 18 Jan 2026 13:23:44 -0600 Subject: add throttling options --- src/slskd/Core/Options.cs | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 68fa4d92..53c94303 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -282,6 +282,12 @@ namespace slskd [Validate] public RetentionOptions Retention { get; init; } = new RetentionOptions(); + /// + /// Gets throttling options. + /// + [Validate] + public ThrottlingOptions Throttling { get; init; } = new ThrottlingOptions(); + /// /// Gets logger options. /// @@ -1461,6 +1467,52 @@ namespace slskd } } + /// + /// Throttling options. + /// + public class ThrottlingOptions + { + /// + /// Gets search throttling options. + /// + [Validate] + public SearchThrottlingOptions Search { get; init; } = new SearchThrottlingOptions(); + + /// + /// Search throttling options. + /// + public class SearchThrottlingOptions + { + /// + /// Gets search response throttling options. + /// + [Validate] + public SearchResponseThrottlingOptions Response { get; init; } = new SearchResponseThrottlingOptions(); + + /// + /// Search response throttling options. + /// + public class SearchResponseThrottlingOptions + { + /// + /// Gets the limit for the number of concurrent search response operations. + /// + [EnvironmentVariable("THROTTLING_SEARCH_RESPONSE_CONCURRENCY")] + [Range(1, 100)] + [RequiresRestart] + public int Concurrency { get; init; } = 10; + + /// + /// Gets the limit for the number of queued search response operations, after which requests will be discarded. + /// + [EnvironmentVariable("THROTTLING_SEARCH_RESPONSE_CIRCUIT_BREAKER")] + [Range(100, 10000)] + [RequiresRestart] + public int CircuitBreaker { get; init; } = 500; + } + } + } + /// /// Metrics options. /// -- cgit v1.2.3