Class SecurityRunner.RateState

java.lang.Object
neqsim.mcp.runners.SecurityRunner.RateState
Enclosing class:
SecurityRunner

static class SecurityRunner.RateState extends Object
Rate limiting state for a user.
Version:
1.0
Author:
Even Solbraa
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final List<Long>
    Timestamps of recent requests.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) long
    getRequestCount(long windowMs)
    Gets the current request count in the window.
    (package private) boolean
    tryRequest(int maxRequests, long windowMs)
    Attempts to make a request within the rate limit.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • requests

      private final List<Long> requests
      Timestamps of recent requests.
  • Constructor Details

    • RateState

      RateState()
  • Method Details

    • tryRequest

      boolean tryRequest(int maxRequests, long windowMs)
      Attempts to make a request within the rate limit.
      Parameters:
      maxRequests - max requests in the window
      windowMs - window duration in milliseconds
      Returns:
      true if allowed
    • getRequestCount

      long getRequestCount(long windowMs)
      Gets the current request count in the window.
      Parameters:
      windowMs - window in ms
      Returns:
      request count