@ParametersAreNonnullByDefault
public class RequestLimitRule
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
int |
getDurationSeconds() |
java.util.Set<java.lang.String> |
getKeys() |
long |
getLimit() |
java.lang.String |
getName() |
int |
getPrecisionSeconds() |
int |
hashCode() |
RequestLimitRule |
matchingKeys(java.util.Set<java.lang.String> keys)
Applies a key to the rate limit that defines to which keys, the rule applies, null for any unmatched key.
|
RequestLimitRule |
matchingKeys(java.lang.String... keys)
Applies a key to the rate limit that defines to which keys, the rule applies, empty for any unmatched key.
|
static RequestLimitRule |
of(java.time.Duration duration,
long limit)
Initialise a request rate limit.
|
RequestLimitRule |
withName(java.lang.String name)
Applies a name to the rate limit that is useful for metrics.
|
RequestLimitRule |
withPrecision(java.time.Duration precision)
Controls (approximate) sliding window precision.
|
public static RequestLimitRule of(java.time.Duration duration, long limit)
duration - The time the limit will be applied over. The duration must be greater than 1 second.limit - A number representing the maximum operations that can be performed in the given duration.public RequestLimitRule withPrecision(java.time.Duration precision)
precision - Defines the time precision that will be used to approximate the sliding window. The precision must be greater than 1 second.public RequestLimitRule withName(java.lang.String name)
name - Defines a descriptive name for the rule limit.public RequestLimitRule matchingKeys(java.lang.String... keys)
keys - Defines a set of keys to which the rule applies.public RequestLimitRule matchingKeys(java.util.Set<java.lang.String> keys)
keys - Defines a set of keys to which the rule applies.public int getDurationSeconds()
public int getPrecisionSeconds()
public java.lang.String getName()
public long getLimit()
@Nullable public java.util.Set<java.lang.String> getKeys()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object