Class Bucket4JBaseConfiguration<R>

java.lang.Object
com.giffing.bucket4j.spring.boot.starter.config.Bucket4JBaseConfiguration<R>
Direct Known Subclasses:
Bucket4JAutoConfigurationServletFilter, Bucket4JAutoConfigurationWebfluxFilter, Bucket4JAutoConfigurationZuul

@Component
public abstract class Bucket4JBaseConfiguration<R>
extends java.lang.Object
Holds helper Methods which are reused by the Bucket4JAutoConfigurationServletFilter and the Bucket4JAutoConfigurationZuul configuration classes
  • Constructor Summary

    Constructors 
    Constructor Description
    Bucket4JBaseConfiguration()  
  • Method Summary

    Modifier and Type Method Description
    com.giffing.bucket4j.spring.boot.starter.context.properties.FilterConfiguration<R> buildFilterConfig​(com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration config, io.github.bucket4j.grid.ProxyManager<java.lang.String> buckets, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)  
    com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler dummyMetricHandler()  
    com.giffing.bucket4j.spring.boot.starter.context.Condition<R> executeCondition​(com.giffing.bucket4j.spring.boot.starter.context.properties.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.
    com.giffing.bucket4j.spring.boot.starter.context.KeyFilter<R> getKeyFilter​(java.lang.String url, com.giffing.bucket4j.spring.boot.starter.context.properties.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.
    com.giffing.bucket4j.spring.boot.starter.context.Condition<R> skipCondition​(com.giffing.bucket4j.spring.boot.starter.context.properties.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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • dummyMetricHandler

      @Bean public com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler dummyMetricHandler()
    • buildFilterConfig

      public com.giffing.bucket4j.spring.boot.starter.context.properties.FilterConfiguration<R> buildFilterConfig​(com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration config, io.github.bucket4j.grid.ProxyManager<java.lang.String> buckets, org.springframework.expression.ExpressionParser expressionParser, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)
    • getKeyFilter

      public com.giffing.bucket4j.spring.boot.starter.context.KeyFilter<R> getKeyFilter​(java.lang.String url, com.giffing.bucket4j.spring.boot.starter.context.properties.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 com.giffing.bucket4j.spring.boot.starter.context.Condition<R> skipCondition​(com.giffing.bucket4j.spring.boot.starter.context.properties.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 com.giffing.bucket4j.spring.boot.starter.context.Condition<R> executeCondition​(com.giffing.bucket4j.spring.boot.starter.context.properties.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.