Class RateLimitResult
java.lang.Object
org.gridgain.internal.mcp.ratelimit.RateLimitResult
Result of a rate limit check.
Contains information about whether the request was allowed and rate limit details.
-
Constructor Summary
ConstructorsConstructorDescriptionRateLimitResult(boolean allowed, int limitPerMinute, int remaining, long retryAfterMs) Creates a rate limit result. -
Method Summary
Modifier and TypeMethodDescriptionintThe configured rate limit (queries per minute).intNumber of remaining tokens/queries available.longMilliseconds until the next token becomes available.longReturns retry time in seconds (rounded up).booleanWhether the request is allowed.booleanChecks if remaining tokens are below the warning threshold (20%).toString()
-
Constructor Details
-
RateLimitResult
public RateLimitResult(boolean allowed, int limitPerMinute, int remaining, long retryAfterMs) Creates a rate limit result.- Parameters:
allowed- Whether the request is allowedlimitPerMinute- The rate limit (queries per minute)remaining- Number of remaining tokensretryAfterMs- Milliseconds until next token available (0 if allowed)
-
-
Method Details
-
isAllowed
public boolean isAllowed()Whether the request is allowed. -
getLimitPerMinute
public int getLimitPerMinute()The configured rate limit (queries per minute). -
getRemaining
public int getRemaining()Number of remaining tokens/queries available. -
getRetryAfterMs
public long getRetryAfterMs()Milliseconds until the next token becomes available. Returns 0 if tokens are currently available. -
getRetryAfterSeconds
public long getRetryAfterSeconds()Returns retry time in seconds (rounded up). -
shouldWarn
public boolean shouldWarn()Checks if remaining tokens are below the warning threshold (20%). -
toString
-