System.Threading.RateLimiting Acquires leases from rate limiters in the order given. If a lease fails to be acquired (throwing or IsAcquired == false) then the already acquired leases are disposed in reverse order and the failing lease is returned or the exception is thrown to user code. implementation that helps manage concurrent access to a resource. Initializes the . Options to specify the behavior of the . Collects registrations to dispose outside the limiter lock to avoid deadlock. Options to specify the behavior of a . Maximum number of permits that can be leased concurrently. Must be set to a value > 0 by the time these options are passed to the constructor of . Determines the behaviour of when not enough resources can be leased. by default. Maximum number of permits that can be queued concurrently. Must be set to a value >= 0 by the time these options are passed to the constructor of . implementation that refreshes allowed permits in a window periodically. Initializes the . Options to specify the behavior of the . Attempts to replenish request counters in the window. False if is enabled, otherwise true. Does not reflect if counters were replenished. Collects registrations to dispose outside the limiter lock to avoid deadlock. Options to specify the behavior of a . Specifies the time window that takes in the requests. Must be set to a value greater than by the time these options are passed to the constructor of . Specified whether the is automatically refresh counters or if someone else will be calling to refresh counters. by default. Maximum number of permit counters that can be allowed in a window. Must be set to a value > 0 by the time these options are passed to the constructor of . Determines the behaviour of when not enough resources can be leased. by default. Maximum cumulative permit count of queued acquisition requests. Must be set to a value >= 0 by the time these options are passed to the constructor of . Contains some common metadata name-type pairs and helper method to create a metadata name. Metadata put on a failed lease acquisition to specify when to retry acquiring a lease. For example, used in which periodically replenishes leases. Metadata put on a failed lease acquisition to specify the reason the lease failed. Create a strongly-typed metadata name. Type that the metadata will contain. Name of the metadata. A strongly-typed name of metadata that can be stored in a . The type the metadata will be. Constructs a object with the given name. The name of the object. Gets the name of the metadata. Determines whether two are equal to each other. Determines whether two are not equal to each other. Contains methods to assist with creating a . Method used to create a default implementation of . The resource type that is being rate limited. The type to distinguish partitions with. Method called every time an Acquire or WaitAsync call is made to figure out what rate limiter to apply to the request. If the matches a cached entry then the rate limiter previously used for that key is used. Otherwise, the factory is called to get a new rate limiter. Optional to customize the comparison logic for . Creates a single that wraps the passed in s. Methods on the returned will iterate over the passed in in the order given. will return the lowest value for , the inner-most limiter's , and the aggregate values for the rest of the properties from the . s returned will aggregate metadata and for duplicates use the value of the first lease with the same metadata name. The resource type that is being rate limited. The s that will be called in order when acquiring resources. is a null parameter. is an empty array. Represents a limiter type that users interact with to determine if an operation can proceed given a specific . The resource type that is being limited. Gets a snapshot of the statistics for the if available. An instance of containing a snapshot of the statistics for a . Fast synchronous attempt to acquire permits. Set to 0 to get whether permits are exhausted. The resource to limit. Number of permits to try and acquire. A successful or failed lease. Method that implementations implement for . The resource to limit. Number of permits to try and acquire. Wait until the requested permits are available or permits can no longer be acquired. Set to 0 to wait until permits are replenished. The resource to limit. Number of permits to try and acquire. Optional token to allow canceling a queued request for permits. A task that completes when the requested permits are acquired or when the requested permits are denied. Method that implementations implement for . The resource to limit. Number of permits to try and acquire. Optional token to allow canceling a queued request for permits. A task that completes when the requested permits are acquired or when the requested permits are denied. Dispose method for implementations to write. Disposes the RateLimiter. This completes any queued acquires with a failed lease. DisposeAsync method for implementations to write. Disposes the RateLimiter asynchronously. ValueTask representing the completion of the disposal. Translates PartitionedRateLimiter<TOuter> into the current using the to translate to . The type to translate into . The function to be called every time a is passed to PartitionedRateLimiter<TOuter>.Acquire(TOuter, int) or PartitionedRateLimiter<TOuter>.WaitAsync(TOuter, int, CancellationToken). should be implemented in a thread-safe way. Specifies whether the returned will dispose the wrapped . A new PartitionedRateLimiter<TOuter> that translates to and calls the inner . Controls the behavior of when not enough resources can be leased. Lease the oldest queued call. Lease the newest queued call. Represents a limiter type that users interact with to determine if an operation can proceed. Gets a snapshot of the statistics if available. An instance of containing a snapshot of the statistics. Specifies how long the has had all permits available. Used by RateLimiter managers that may want to clean up unused RateLimiters. Returns when the is in use or is not ready to be idle. Fast synchronous attempt to acquire permits. Set to 0 to get whether permits are exhausted. Number of permits to try and acquire. A successful or failed lease. Method that implementations implement for . Number of permits to try and acquire. Wait until the requested permits are available or permits can no longer be acquired. Set to 0 to wait until permits are replenished. Number of permits to try and acquire. Optional token to allow canceling a queued request for permits. A task that completes when the requested permits are acquired or when the requested permits are denied. Method that implementations implement for . Number of permits to try and acquire. Optional token to allow canceling a queued request for permits. A task that completes when the requested permits are acquired or when the requested permits are denied. Dispose method for implementations to write. Disposes the RateLimiter. This completes any queued acquires with a failed lease. DisposeAsync method for implementations to write. Disposes the RateLimiter asynchronously. ValueTask representing the completion of the disposal. Snapshot of statistics for a . Initializes an instance of . Gets the number of permits currently available for the . Gets the number of queued permits for the . Gets the total number of failed s returned. Gets the total number of successful s returned. Abstraction for leases returned by implementations. A lease represents the success or failure to acquire a resource and contains potential metadata that is relevant to the acquisition operation. Represents whether lease acquisition was successful. Attempt to extract metadata for the lease. The name of the metadata. Some common ones can be found in . The metadata object if it exists. True if the metadata exists, otherwise false. Attempt to extract a strongly-typed metadata for the lease. Type of the expected metadata. The name of the strongly-typed metadata. Some common ones can be found in . The strongly-typed metadata object if it exists. True if the metadata exists, otherwise false. Gets a list of the metadata names that are available on the lease. Gets a list of all the metadata that is available on the lease. List of key-value pairs of metadata name and metadata object. Dispose the lease. This may free up space on the limiter implementation the lease came from. Dispose method for implementations to write. Contains methods used in to assist in the creation of partitions for your rate limiter. Defines a partition with the given rate limiter factory. The type to distinguish partitions with. The should return a new instance of a rate limiter every time it is called. The specific key for this partition. This will be used to check for an existing cached limiter before calling the . The function called when a rate limiter for the given is needed. This should be a new instance of a rate limiter every time it is called. Defines a partition with a with the given . The type to distinguish partitions with. The specific key for this partition. This will be used to check for an existing cached limiter before calling the . The function called when a rate limiter for the given is needed. This can return the same instance of across different calls. Defines a partition that will not have a rate limiter. This means any calls to or will always succeed for the given . The type to distinguish partitions with. The specific key for this partition. Defines a partition with a with the given . Set to to save an allocation. This method will create a new options type and set to otherwise. The type to distinguish partitions with. The specific key for this partition. The function called when a rate limiter for the given is needed. This can return the same instance of across different calls. Defines a partition with a with the given . Set to to save an allocation. This method will create a new options type and set to otherwise. The type to distinguish partitions with. The specific key for this partition. The function called when a rate limiter for the given is needed. This can return the same instance of across different calls. Defines a partition with a with the given . Set to to save an allocation. This method will create a new options type and set to otherwise. The type to distinguish partitions with. The specific key for this partition. The function called when a rate limiter for the given is needed. This can return the same instance of across different calls. Type returned by methods to be used by to know what partitions are configured. The type to distinguish partitions with. Constructs the for use in . The specific key for this partition. The function called when a rate limiter for the given is needed. The specific key for this partition. The function called when a rate limiter for the given partitionKey is needed. Abstraction that specifies that the implementation is capable of replenishing tokens. Specifies how often the will replenish tokens. If is then this is how often should be called. Specifies if the is automatically replenishing its tokens or if it expects an external source to regularly call . Attempts to replenish tokens. Generally returns if is enabled or if no tokens were replenished. Otherwise . implementation that replenishes permit counters periodically instead of via a release mechanism. Initializes the . Options to specify the behavior of the . Attempts to replenish request counters in a window. False if is enabled, otherwise true. Does not reflect if permits were replenished. Collects registrations to dispose outside the limiter lock to avoid deadlock. Options to specify the behavior of a . Specifies the minimum period between replenishments. Must be set to a value greater than by the time these options are passed to the constructor of . Specifies the maximum number of segments a window is divided into. Must be set to a value > 0 by the time these options are passed to the constructor of . Specified whether the is automatically replenishing request counters or if someone else will be calling to replenish tokens. by default. Maximum number of requests that can be served in a window. Must be set to a value > 0 by the time these options are passed to the constructor of . Determines the behaviour of when not enough resources can be leased. by default. Maximum cumulative permit count of queued acquisition requests. Must be set to a value >= 0 by the time these options are passed to the constructor of . implementation that replenishes tokens periodically instead of via a release mechanism. Initializes the . Options to specify the behavior of the . Attempts to replenish the bucket. if is enabled, otherwise . Does not reflect if tokens were replenished. Collects registrations to dispose outside the limiter lock to avoid deadlock. Options to control the behavior of a . Specifies the minimum period between replenishments. Must be set to a value greater than by the time these options are passed to the constructor of . Specifies the maximum number of tokens to restore each replenishment. Must be set to a value > 0 by the time these options are passed to the constructor of . Specified whether the is automatically replenishing tokens or if someone else will be calling to replenish tokens. by default. Maximum number of tokens that can be in the bucket at any time. Must be set to a value > 0 by the time these options are passed to the constructor of . Determines the behaviour of when not enough resources can be leased. by default. Maximum cumulative token count of queued acquisition requests. Must be set to a value >= 0 by the time these options are passed to the constructor of . Provides a double-ended queue data structure. Type of the data stored in the dequeue. {0} token(s) exceeds the token limit of {1}. {0} permit(s) exceeds the permit limit of {1}. Over 49 days is not supported. {0} must be set to a value greater than 0. {0} must be set to a value greater than or equal to 0. {0} must be set to a value greater than TimeSpan.Zero. Attribute used to indicate a source generator should create a function for marshalling arguments instead of relying on the runtime to generate an equivalent marshalling function at run-time. This attribute is meaningless if the source generator associated with it is not enabled. The current built-in source generator only supports C# and only supplies an implementation when applied to static, partial, non-generic methods. Initializes a new instance of the . Name of the library containing the import. Gets the name of the library containing the import. Gets or sets the name of the entry point to be called. Gets or sets how to marshal string arguments to the method. If this field is set to a value other than , must not be specified. Gets or sets the used to control how string arguments to the method are marshalled. If this field is specified, must not be specified or must be set to . Gets or sets whether the callee sets an error (SetLastError on Windows or errno on other platforms) before returning from the attributed method. Specifies how strings should be marshalled for generated p/invokes Indicates the user is suppling a specific marshaller in . Use the platform-provided UTF-8 marshaller. Use the platform-provided UTF-16 marshaller.