public class RedisRateLimiter extends AbstractRateLimiter<RedisRateLimiter.Config> implements org.springframework.context.ApplicationContextAware
Modifier and Type | Class and Description |
---|---|
static class |
RedisRateLimiter.Config |
RateLimiter.Response
Modifier and Type | Field and Description |
---|---|
static String |
BURST_CAPACITY_KEY
Deprecated.
|
static String |
CONFIGURATION_PROPERTY_NAME |
static String |
REDIS_SCRIPT_NAME |
static String |
REPLENISH_RATE_KEY
Deprecated.
|
Constructor and Description |
---|
RedisRateLimiter(int defaultReplenishRate,
int defaultBurstCapacity) |
RedisRateLimiter(org.springframework.data.redis.core.ReactiveRedisTemplate<String,String> redisTemplate,
org.springframework.data.redis.core.script.RedisScript<List<Long>> script,
org.springframework.validation.Validator validator) |
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<RateLimiter.Response> |
isAllowed(String routeId,
String id)
This uses a basic token bucket algorithm and relies on the fact that Redis scripts
execute atomically.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext context) |
getConfigurationPropertyName, getValidator, onApplicationEvent, setValidator, toString
getConfig
getConfigClass, newConfig
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getConfig
getConfigClass, newConfig
@Deprecated public static final String REPLENISH_RATE_KEY
@Deprecated public static final String BURST_CAPACITY_KEY
public static final String CONFIGURATION_PROPERTY_NAME
public static final String REDIS_SCRIPT_NAME
public RedisRateLimiter(org.springframework.data.redis.core.ReactiveRedisTemplate<String,String> redisTemplate, org.springframework.data.redis.core.script.RedisScript<List<Long>> script, org.springframework.validation.Validator validator)
public RedisRateLimiter(int defaultReplenishRate, int defaultBurstCapacity)
public void setApplicationContext(org.springframework.context.ApplicationContext context) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public reactor.core.publisher.Mono<RateLimiter.Response> isAllowed(String routeId, String id)
isAllowed
in interface RateLimiter<RedisRateLimiter.Config>
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.