diff --git a/projects/RabbitMQ.Client/CreateChannelOptions.cs b/projects/RabbitMQ.Client/CreateChannelOptions.cs index 4fb04afd6..982316a05 100644 --- a/projects/RabbitMQ.Client/CreateChannelOptions.cs +++ b/projects/RabbitMQ.Client/CreateChannelOptions.cs @@ -52,7 +52,10 @@ public sealed class CreateChannelOptions /// /// If the publisher confirmation tracking is enabled, this represents the rate limiter used to /// throttle additional attempts to publish once the threshold is reached. + /// + /// Defaults to a with a limit of 128 and a throttling percentage of 50% with a delay during throttling. /// + /// Setting the rate limiter to null disables the rate limiting entirely. public RateLimiter? OutstandingPublisherConfirmationsRateLimiter { get; set; } = new ThrottlingRateLimiter(128); /// diff --git a/projects/RabbitMQ.Client/ThrottlingRateLimiter.cs b/projects/RabbitMQ.Client/ThrottlingRateLimiter.cs index 9d2521375..71dc2fd05 100644 --- a/projects/RabbitMQ.Client/ThrottlingRateLimiter.cs +++ b/projects/RabbitMQ.Client/ThrottlingRateLimiter.cs @@ -36,14 +36,34 @@ namespace RabbitMQ.Client { + /// + /// A rate limiter that controls the rate of operations by limiting concurrency and applying delays + /// when a specified threshold of concurrency usage is reached. + /// + /// The delay algorithm checks the current available permits from the concurrency limiter. If the available permits are greater than or equal + /// to the throttling threshold, no delay is applied. Otherwise, it calculates a delay based on the percentage of permits used, + /// scaling it up to a maximum of 1000 milliseconds. + /// public class ThrottlingRateLimiter : RateLimiter { + /// + /// The default throttling percentage, which defines the threshold for applying throttling, set to 50%. + /// public const int DefaultThrottlingPercentage = 50; private readonly ConcurrencyLimiter _concurrencyLimiter; private readonly int _maxConcurrency; private readonly int _throttlingThreshold; + /// + /// Initializes a new instance of the class with the specified + /// maximum number of concurrent calls and an optional throttling percentage. + /// + /// The maximum number of concurrent operations allowed. + /// + /// The percentage of at which throttling is triggered. + /// Defaults to 50% if not specified. + /// public ThrottlingRateLimiter(int maxConcurrentCalls, int? throttlingPercentage = DefaultThrottlingPercentage) { _maxConcurrency = maxConcurrentCalls;