diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-01-18 13:23:44 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-01-18 13:23:44 -0600 |
| commit | 572aa0502b325fc9657eef774f034a43a7078e1a (patch) | |
| tree | dbde8fa65f87f78f36e972b8412b37c12601f99f | |
| parent | 92a9064c50775aa4814760b9617b4f904a116a5a (diff) | |
| download | slskd-572aa0502b325fc9657eef774f034a43a7078e1a.tar.gz | |
add throttling options
| -rw-r--r-- | src/slskd/Core/Options.cs | 52 |
1 files changed, 52 insertions, 0 deletions
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 @@ -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,52 @@ 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 search response throttling options. + /// </summary> + [Validate] + public SearchResponseThrottlingOptions Response { get; init; } = new SearchResponseThrottlingOptions(); + + /// <summary> + /// Search response throttling options. + /// </summary> + public class SearchResponseThrottlingOptions + { + /// <summary> + /// Gets the limit for the number of concurrent search response operations. + /// </summary> + [EnvironmentVariable("THROTTLING_SEARCH_RESPONSE_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> + [EnvironmentVariable("THROTTLING_SEARCH_RESPONSE_CIRCUIT_BREAKER")] + [Range(100, 10000)] + [RequiresRestart] + public int CircuitBreaker { get; init; } = 500; + } + } + } + + /// <summary> /// Metrics options. /// </summary> public class MetricsOptions |
