Skip to content

Commit af007e1

Browse files
Xml doc updates for the rate limiting (#1711)
* Describe the option better * Describe the rate limiter --------- Co-authored-by: danielmarbach <[email protected]>
1 parent e51f6bc commit af007e1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

projects/RabbitMQ.Client/CreateChannelOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public sealed class CreateChannelOptions
5252
/// <summary>
5353
/// If the publisher confirmation tracking is enabled, this represents the rate limiter used to
5454
/// throttle additional attempts to publish once the threshold is reached.
55+
///
56+
/// Defaults to a <see cref="ThrottlingRateLimiter"/> with a limit of 128 and a throttling percentage of 50% with a delay during throttling.
5557
/// </summary>
58+
/// <remarks>Setting the rate limiter to <c>null</c> disables the rate limiting entirely.</remarks>
5659
public RateLimiter? OutstandingPublisherConfirmationsRateLimiter { get; set; } = new ThrottlingRateLimiter(128);
5760

5861
/// <summary>

projects/RabbitMQ.Client/ThrottlingRateLimiter.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,34 @@
3636

3737
namespace RabbitMQ.Client
3838
{
39+
/// <summary>
40+
/// A rate limiter that controls the rate of operations by limiting concurrency and applying delays
41+
/// when a specified threshold of concurrency usage is reached.
42+
///
43+
/// The delay algorithm checks the current available permits from the concurrency limiter. If the available permits are greater than or equal
44+
/// to the throttling threshold, no delay is applied. Otherwise, it calculates a delay based on the percentage of permits used,
45+
/// scaling it up to a maximum of 1000 milliseconds.
46+
/// </summary>
3947
public class ThrottlingRateLimiter : RateLimiter
4048
{
49+
/// <summary>
50+
/// The default throttling percentage, which defines the threshold for applying throttling, set to 50%.
51+
/// </summary>
4152
public const int DefaultThrottlingPercentage = 50;
4253

4354
private readonly ConcurrencyLimiter _concurrencyLimiter;
4455
private readonly int _maxConcurrency;
4556
private readonly int _throttlingThreshold;
4657

58+
/// <summary>
59+
/// Initializes a new instance of the <see cref="ThrottlingRateLimiter"/> class with the specified
60+
/// maximum number of concurrent calls and an optional throttling percentage.
61+
/// </summary>
62+
/// <param name="maxConcurrentCalls">The maximum number of concurrent operations allowed.</param>
63+
/// <param name="throttlingPercentage">
64+
/// The percentage of <paramref name="maxConcurrentCalls"/> at which throttling is triggered.
65+
/// Defaults to 50% if not specified.
66+
/// </param>
4767
public ThrottlingRateLimiter(int maxConcurrentCalls, int? throttlingPercentage = DefaultThrottlingPercentage)
4868
{
4969
_maxConcurrency = maxConcurrentCalls;

0 commit comments

Comments
 (0)