Class Bucket4JBaseConfiguration<R>
java.lang.Object
com.giffing.bucket4j.spring.boot.starter.config.Bucket4JBaseConfiguration<R>
- Direct Known Subclasses:
Bucket4JAutoConfigurationServletFilter,Bucket4JAutoConfigurationSpringCloudGatewayFilter,Bucket4JAutoConfigurationWebfluxFilter
public abstract class Bucket4JBaseConfiguration<R> extends Object
Holds helper Methods which are reused by the
Bucket4JAutoConfigurationServletFilter
Bucket4JAutoConfigurationSpringCloudGatewayFilter
Bucket4JAutoConfigurationWebfluxFilter
configuration classes-
Constructor Summary
Constructors Constructor Description Bucket4JBaseConfiguration() -
Method Summary
Modifier and Type Method Description protected voidaddDefaultMetricTags(Bucket4JBootProperties properties, Bucket4JConfiguration filter)FilterConfiguration<R>buildFilterConfig(Bucket4JConfiguration config, io.github.bucket4j.distributed.proxy.ProxyManager<String> buckets, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)Condition<R>executeCondition(RateLimit rateLimit, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.BeanFactory beanFactory)Creates the lambda for the execute condition which will be evaluated on each request.KeyFilter<R>getKeyFilter(String url, RateLimit rateLimit, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.BeanFactory beanFactory)Creates the key filter lambda which is responsible to decide how the rate limit will be performed.abstract List<MetricHandler>getMetricHandlers()Condition<R>skipCondition(RateLimit rateLimit, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.BeanFactory beanFactory)Creates the lambda for the skip condition which will be evaluated on each request
-
Constructor Details
-
Bucket4JBaseConfiguration
public Bucket4JBaseConfiguration()
-
-
Method Details
-
getMetricHandlers
-
buildFilterConfig
public FilterConfiguration<R> buildFilterConfig(Bucket4JConfiguration config, io.github.bucket4j.distributed.proxy.ProxyManager<String> buckets, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory) -
getKeyFilter
public KeyFilter<R> getKeyFilter(String url, RateLimit rateLimit, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.BeanFactory beanFactory)Creates the key filter lambda which is responsible to decide how the rate limit will be performed. The key is the unique identifier like an IP address or a username.- Parameters:
url- is used to generated a unique cache keyrateLimit- theRateLimitconfiguration which holds the skip condition stringexpressionParser- is used to evaluate the expression if the filter key type is EXPRESSION.beanFactory- used to get full access to all java beans in the SpEl- Returns:
- should not been null. If no filter key type is matching a plain 1 is returned so that all requests uses the same key.
-
skipCondition
public Condition<R> skipCondition(RateLimit rateLimit, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.BeanFactory beanFactory)Creates the lambda for the skip condition which will be evaluated on each request- Parameters:
rateLimit- theRateLimitconfiguration which holds the skip condition stringexpressionParser- is used to evaluate the skip expressionbeanFactory- used to get full access to all java beans in the SpEl- Returns:
- the lamdba condition which will be evaluated lazy - null if there is no condition available.
-
executeCondition
public Condition<R> executeCondition(RateLimit rateLimit, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.BeanFactory beanFactory)Creates the lambda for the execute condition which will be evaluated on each request.- Parameters:
rateLimit- theRateLimitconfiguration which holds the execute condition stringexpressionParser- is used to evaluate the execution expressionbeanFactory- used to get full access to all java beans in the SpEl- Returns:
- the lamdba condition which will be evaluated lazy - null if there is no condition available.
-
addDefaultMetricTags
protected void addDefaultMetricTags(Bucket4JBootProperties properties, Bucket4JConfiguration filter)
-