RateLimiterOptionsExtensions.AddTokenBucketLimiter Method

Definition

Registers a new TokenBucketRateLimiter with the given TokenBucketRateLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

public static Microsoft.AspNetCore.RateLimiting.RateLimiterOptions AddTokenBucketLimiter (this Microsoft.AspNetCore.RateLimiting.RateLimiterOptions options, string policyName, Action<System.Threading.RateLimiting.TokenBucketRateLimiterOptions> configureOptions);
static member AddTokenBucketLimiter : Microsoft.AspNetCore.RateLimiting.RateLimiterOptions * string * Action<System.Threading.RateLimiting.TokenBucketRateLimiterOptions> -> Microsoft.AspNetCore.RateLimiting.RateLimiterOptions
<Extension()>
Public Function AddTokenBucketLimiter (options As RateLimiterOptions, policyName As String, configureOptions As Action(Of TokenBucketRateLimiterOptions)) As RateLimiterOptions

Parameters

options
RateLimiterOptions

The RateLimiterOptions to add a limiter to.

policyName
String

The name that will be associated with the limiter.

configureOptions
Action<TokenBucketRateLimiterOptions>

A callback to configure the TokenBucketRateLimiterOptions to be used for the limiter.

Returns

This RateLimiterOptions.

Remarks

Setting AutoReplenishment will have no effect here, as the PartitionedRateLimiter that this limiter is added to will control replenishing it.

Applies to