Class SecurityRunner.RateState
java.lang.Object
neqsim.mcp.runners.SecurityRunner.RateState
- Enclosing class:
SecurityRunner
Rate limiting state for a user.
- Version:
- 1.0
- Author:
- Even Solbraa
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) longgetRequestCount(long windowMs) Gets the current request count in the window.(package private) booleantryRequest(int maxRequests, long windowMs) Attempts to make a request within the rate limit.
-
Field Details
-
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 windowwindowMs- 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
-