Class FastRateLimiter

  • All Implemented Interfaces:
    RateLimiter

    public class FastRateLimiter
    extends java.lang.Object
    implements RateLimiter
    A RateLimiter that compromises accuracy for speed in order to provide maximum throughput.
    • Constructor Detail

      • FastRateLimiter

        public FastRateLimiter()
    • Method Detail

      • getPolicyName

        public java.lang.String getPolicyName()
        Specified by:
        getPolicyName in interface RateLimiter
        Returns:
        name of RateLimit policy
      • setPolicyName

        public void setPolicyName​(java.lang.String name)
        Description copied from interface: RateLimiter
        Sets the policy name, otherwise an auto-generated name is used.
        Specified by:
        setPolicyName in interface RateLimiter
        Parameters:
        name - of rate limit policy
      • getDuration

        public int getDuration()
        Specified by:
        getDuration in interface RateLimiter
        Returns:
        the actual duration of a time window in seconds
      • setDuration

        public void setDuration​(int duration)
        Description copied from interface: RateLimiter
        Sets the configured duration value in seconds.
        Specified by:
        setDuration in interface RateLimiter
        Parameters:
        duration - The duration of the time window in seconds
      • getRequests

        public int getRequests()
        Specified by:
        getRequests in interface RateLimiter
        Returns:
        the maximum number of requests allowed per time window
      • setRequests

        public void setRequests​(int requests)
        Description copied from interface: RateLimiter
        Sets the configured number of requests allowed per time window.
        Specified by:
        setRequests in interface RateLimiter
        Parameters:
        requests - The number of requests per time window
      • increment

        public int increment​(java.lang.String ipAddress)
        Description copied from interface: RateLimiter
        Increments the number of requests by the given ipAddress in the current time window.
        Specified by:
        increment in interface RateLimiter
        Parameters:
        ipAddress - the ip address
        Returns:
        the new value after incrementing
      • destroy

        public void destroy()
        Description copied from interface: RateLimiter
        Cleanup no longer needed resources.
        Specified by:
        destroy in interface RateLimiter
      • setFilterConfig

        public void setFilterConfig​(FilterConfig filterConfig)
        Description copied from interface: RateLimiter
        Pass the FilterConfig to configure the filter.
        Specified by:
        setFilterConfig in interface RateLimiter
        Parameters:
        filterConfig - The FilterConfig used to configure the associated filter