Class RateLimitSpec
java.lang.Object
org.frontcache.guard.ratelimit.RateLimitSpec
The parsed form of a
rate: predicate, computed once at load time.
rate:<limit>/<window> [bucket=<name>] [scope=<toplevel|all>] rate:100/10s 100 requests per 10-second slot, per IP rate:10/s a bare unit means 1, so this is 10 per second rate:10/1m bucket=login shares its counter with any other rule naming bucket 'login'
bucket defaults to the rule name, which is resolved by the rule parser - the predicate
factory does not know it. That default is deliberate: it makes a dry-run rule and a live rule
separate counters, so a stricter limit can be measured against real traffic while the current one
still enforces.-
Method Summary
Modifier and TypeMethodDescriptionintgetLimit()longbooleanstatic RateLimitSpecwithDefaultBucket(String ruleName)
-
Method Details
-
parse
- Parameters:
arg- everything after "rate:"expr- the whole predicate as written, used in messages and by describe()
-
withDefaultBucket
- Returns:
- a copy with the bucket resolved, called by the rule parser once the rule name is known
-
getLimit
public int getLimit() -
getWindowMillis
public long getWindowMillis() -
getBucket
-
isToplevelOnly
public boolean isToplevelOnly() -
getSource
-