Method SetClientFixedWindowGlobalLimiter
SetClientFixedWindowGlobalLimiter(RateLimiterOptions, int, TimeSpan)
Sets the global limiter, which applies to every request, to a limiter that allows each client address a fixed number of requests per window.
Declaration
public static RateLimiterOptions SetClientFixedWindowGlobalLimiter(this RateLimiterOptions options, int permitLimit, TimeSpan window)
Parameters
| Type | Name | Description |
|---|---|---|
| RateLimiterOptions | options | The rate limiter options. |
| int | permitLimit | The number of requests each client can make in each window (see PermitLimit). |
| TimeSpan | window | The length of a window (see Window). |
Returns
| Type | Description |
|---|---|
| RateLimiterOptions |
Remarks
See ClientRateLimitOptions for how clients are identified and which clients are exempt. The configurations added with
ConfigureClientLimits(RateLimiterOptions, Action<ClientRateLimitOptions>) before this call run before configure. Endpoint policies (see
AddClientFixedWindowLimiter(RateLimiterOptions, string, Action<ClientRateLimitOptions>)) apply in addition to the global limiter.
If OnRejected is not set, this also sets the rejection response with SetApiRejectionResponse(RateLimiterOptions, string?).
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| FormatException | An entry in ExemptNetworks is not a valid address or network. |
SetClientFixedWindowGlobalLimiter(RateLimiterOptions, Action<ClientRateLimitOptions>)
Sets the global limiter, which applies to every request, to a limiter that allows each client address a fixed number of requests per window.
Declaration
public static RateLimiterOptions SetClientFixedWindowGlobalLimiter(this RateLimiterOptions options, Action<ClientRateLimitOptions> configure)
Parameters
| Type | Name | Description |
|---|---|---|
| RateLimiterOptions | options | The rate limiter options. |
| Action<ClientRateLimitOptions> | configure | An action to configure the limit. PermitLimit must be set. |
Returns
| Type | Description |
|---|---|
| RateLimiterOptions |
Remarks
See ClientRateLimitOptions for how clients are identified and which clients are exempt. The configurations added with
ConfigureClientLimits(RateLimiterOptions, Action<ClientRateLimitOptions>) before this call run before configure. Endpoint policies (see
AddClientFixedWindowLimiter(RateLimiterOptions, string, Action<ClientRateLimitOptions>)) apply in addition to the global limiter.
If OnRejected is not set, this also sets the rejection response with SetApiRejectionResponse(RateLimiterOptions, string?).
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | PermitLimit was not set. |
| FormatException | An entry in ExemptNetworks is not a valid address or network. |