diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-01-19 12:53:17 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-19 12:53:17 -0600 |
| commit | 6fdc317978fd91fbfd5828ee72c7e7f19c316b13 (patch) | |
| tree | 0370a03f1fadda7e6d4979cb4ee46c4d75880e8d /src/slskd/Core/Options.cs | |
| parent | 9c1c726f2de69dd3fd38740f5bdb7f1f76e97fcf (diff) | |
| parent | 5b302ae5f2e0c01cb111a37680d63df3d47b114d (diff) | |
| download | slskd-6fdc317978fd91fbfd5828ee72c7e7f19c316b13.tar.gz | |
Merge pull request #1608 from slskd/search-metrics
Add throttling for incoming search requests, add additional prometheus metrics covering search responses
Diffstat (limited to 'src/slskd/Core/Options.cs')
| -rw-r--r-- | src/slskd/Core/Options.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 68fa4d92..200b0ee8 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -283,6 +283,12 @@ namespace slskd public RetentionOptions Retention { get; init; } = new RetentionOptions(); /// <summary> + /// Gets throttling options. + /// </summary> + [Validate] + public ThrottlingOptions Throttling { get; init; } = new ThrottlingOptions(); + + /// <summary> /// Gets logger options. /// </summary> [Validate] @@ -1462,6 +1468,61 @@ namespace slskd } /// <summary> + /// Throttling options. + /// </summary> + public class ThrottlingOptions + { + /// <summary> + /// Gets search throttling options. + /// </summary> + [Validate] + public SearchThrottlingOptions Search { get; init; } = new SearchThrottlingOptions(); + + /// <summary> + /// Search throttling options. + /// </summary> + public class SearchThrottlingOptions + { + /// <summary> + /// Gets incoming search throttling options. + /// </summary> + [Validate] + public IncomingSearchThrottlingOptions Incoming { get; init; } = new IncomingSearchThrottlingOptions(); + + /// <summary> + /// Search response throttling options. + /// </summary> + public class IncomingSearchThrottlingOptions + { + /// <summary> + /// Gets the limit for the number of concurrent search response operations. + /// </summary> + [Argument(default, "throttling-search-incoming-concurrency")] + [EnvironmentVariable("THROTTLING_SEARCH_INCOMING_CONCURRENCY")] + [Range(1, 100)] + [RequiresRestart] + public int Concurrency { get; init; } = 10; + + /// <summary> + /// Gets the limit for the number of queued search response operations, after which requests will be discarded. + /// </summary> + [Argument(default, "throttling-search-incoming-circuit-breaker")] + [EnvironmentVariable("THROTTLING_SEARCH_INCOMING_CIRCUIT_BREAKER")] + [Range(100, 10000)] + public int CircuitBreaker { get; init; } = 500; + + /// <summary> + /// Gets the limit for the number of files that can be returned in a single search request. + /// </summary> + [Argument(default, "throttling-search-incoming-response-file-limit")] + [EnvironmentVariable("THROTTLING_SEARCH_INCOMING_RESPONSE_FILE_LIMIT")] + [Range(100, 5000)] + public int ResponseFileLimit { get; init; } = 500; + } + } + } + + /// <summary> /// Metrics options. /// </summary> public class MetricsOptions |
