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
  • Constructor Details

    • Bucket4JBaseConfiguration

      public Bucket4JBaseConfiguration()
  • Method Details

    • getMetricHandlers

      public abstract List<MetricHandler> 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 key
      rateLimit - the RateLimit configuration which holds the skip condition string
      expressionParser - 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 - the RateLimit configuration which holds the skip condition string
      expressionParser - is used to evaluate the skip expression
      beanFactory - 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 - the RateLimit configuration which holds the execute condition string
      expressionParser - is used to evaluate the execution expression
      beanFactory - 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)