RateLimiter (Apache Tomcat 10.1.48 API Documentation)
Description: declaration: package: org.apache.catalina.util, interface: RateLimiter

# Interface RateLimiter

All Known Implementing Classes:
  `ExactRateLimiter, FastRateLimiter, RateLimiterBase`

public interface RateLimiter

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `destroy()`
  Cleanup no longer needed resources.
  `int`
  `getDuration()`
  `default String`
  `getPolicy()`
  `String`
  `getPolicyName()`
  `default String`
  `getQuota(int requestCount)`
  Provide the quota header for this rate limit for a given request count within the current time window.
  `int`
  `getRequests()`
  `int`
  `increment(String identifier)`
  Increments the number of requests by the given identifier in the current time window.
  `void`
  `setDuration(int duration)`
  Sets the configured duration value in seconds.
  `void`
  `setFilterConfig(FilterConfig filterConfig)`
  Pass the FilterConfig to configure the filter.
  `void`
  `setPolicyName(String name)`
  Sets the policy name, otherwise an auto-generated name is used.
  `void`
  `setRequests(int requests)`
  Sets the configured number of requests allowed per time window.

- ## Method Details

  - ### getDuration

    int getDuration()
    Returns:
      the actual duration of a time window in seconds

  - ### setDuration

    void setDuration(int duration)
    Sets the configured duration value in seconds.
    Parameters:
      `duration` - The duration of the time window in seconds

  - ### getRequests

    int getRequests()
    Returns:
      the maximum number of requests allowed per time window

  - ### setRequests

    void setRequests(int requests)
    Sets the configured number of requests allowed per time window.
    Parameters:
      `requests` - The number of requests per time window

  - ### increment

    int increment(String identifier)
    Increments the number of requests by the given identifier in the current time window.
    Parameters:
      `identifier` - the identifier for which the number of associated requests should be incremented
    Returns:
      the new value after incrementing

  - ### destroy

    void destroy()
    Cleanup no longer needed resources.

  - ### setFilterConfig

    void setFilterConfig(FilterConfig filterConfig)
    Pass the FilterConfig to configure the filter.
    Parameters:
      `filterConfig` - The FilterConfig used to configure the associated filter

  - ### getPolicyName

    String getPolicyName()
    Returns:
      name of RateLimit policy

  - ### setPolicyName

    void setPolicyName(String name)
    Sets the policy name, otherwise an auto-generated name is used.
    Parameters:
      `name` - of rate limit policy

  - ### getPolicy

    default String getPolicy()
    Returns:
      full representation of current policy
    See Also:
      - RateLimit header fields for HTTP (draft)

  - ### getQuota

    default String getQuota(int requestCount)
    Provide the quota header for this rate limit for a given request count within the current time window.
    Parameters:
      `requestCount` - The request count within the current time window
    Returns:
      the quota header for the given value of request count
    See Also:
      - RateLimit header fields for HTTP (draft)