Class ServletLimiterBuilder
- java.lang.Object
-
- com.netflix.concurrency.limits.limiter.AbstractLimiter.Builder<BuilderT>
-
- com.netflix.concurrency.limits.limiter.AbstractPartitionedLimiter.Builder<ServletLimiterBuilder,jakarta.servlet.http.HttpServletRequest>
-
- com.netflix.concurrency.limits.servlet.jakarta.ServletLimiterBuilder
-
public final class ServletLimiterBuilder extends com.netflix.concurrency.limits.limiter.AbstractPartitionedLimiter.Builder<ServletLimiterBuilder,jakarta.servlet.http.HttpServletRequest>
Builder to simplify creating aLimiterspecific to a Servlet filter. By default, the same concurrency limit is shared by all requests. The limiter can be partitioned based on one of many request attributes. Only one type of partition may be specified.
-
-
Constructor Summary
Constructors Constructor Description ServletLimiterBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServletLimiterBuilderbypassLimitByAttribute(java.lang.String name, java.lang.String value)Bypass limit if the value of the provided attribute name matches the specified value.ServletLimiterBuilderbypassLimitByHeader(java.lang.String name, java.lang.String value)Bypass limit if the value of the provided header name matches the specified value.ServletLimiterBuilderbypassLimitByMethod(java.lang.String method)Bypass limit if the request method matches the specified method.ServletLimiterBuilderbypassLimitByParameter(java.lang.String name, java.lang.String value)Bypass limit if the value of the provided parameter name matches the specified value.ServletLimiterBuilderbypassLimitByPathInfo(java.lang.String pathInfo)Bypass limit if the request path info matches the specified path.ServletLimiterBuilderbypassLimitResolver(java.util.function.Predicate<jakarta.servlet.http.HttpServletRequest> shouldBypass)Add a chainable bypass resolver predicate from context.ServletLimiterBuilderpartitionByAttribute(java.lang.String name)Partition the limit by request attributeServletLimiterBuilderpartitionByHeader(java.lang.String name)Partition the limit by headerServletLimiterBuilderpartitionByParameter(java.lang.String name)Partition the limit by request parameterServletLimiterBuilderpartitionByPathInfo(java.util.function.Function<java.lang.String,java.lang.String> pathToGroup)Partition the limit by the full path.ServletLimiterBuilderpartitionByUserPrincipal(java.util.function.Function<java.security.Principal,java.lang.String> principalToGroup)Partition the limit byPrincipal.protected ServletLimiterBuilderself()-
Methods inherited from class com.netflix.concurrency.limits.limiter.AbstractPartitionedLimiter.Builder
build, hasPartitions, maxDelayedThreads, partition, partitionRejectDelay, partitionResolver
-
-
-
-
Method Detail
-
partitionByHeader
public ServletLimiterBuilder partitionByHeader(java.lang.String name)
Partition the limit by header- Returns:
- Chainable builder
-
partitionByUserPrincipal
public ServletLimiterBuilder partitionByUserPrincipal(java.util.function.Function<java.security.Principal,java.lang.String> principalToGroup)
Partition the limit byPrincipal. Percentages of the limit are partitioned to named groups. Group membership is derived from the provided mapping function.- Parameters:
principalToGroup- Mapping function fromPrincipalto a named group.- Returns:
- Chainable builder
-
partitionByAttribute
public ServletLimiterBuilder partitionByAttribute(java.lang.String name)
Partition the limit by request attribute- Returns:
- Chainable builder
-
partitionByParameter
public ServletLimiterBuilder partitionByParameter(java.lang.String name)
Partition the limit by request parameter- Returns:
- Chainable builder
-
partitionByPathInfo
public ServletLimiterBuilder partitionByPathInfo(java.util.function.Function<java.lang.String,java.lang.String> pathToGroup)
Partition the limit by the full path. Percentages of the limit are partitioned to named groups. Group membership is derived from the provided mapping function.- Parameters:
pathToGroup- Mapping function from full path to a named group.- Returns:
- Chainable builder
-
bypassLimitResolver
public ServletLimiterBuilder bypassLimitResolver(java.util.function.Predicate<jakarta.servlet.http.HttpServletRequest> shouldBypass)
Add a chainable bypass resolver predicate from context. Multiple resolvers may be added and if any of the predicate condition returns true the call is bypassed without increasing the limiter inflight count and affecting the algorithm. Will not bypass any calls by default if no resolvers are added.- Parameters:
shouldBypass- Predicate condition to bypass limit- Returns:
- Chainable builder
-
bypassLimitByHeader
public ServletLimiterBuilder bypassLimitByHeader(java.lang.String name, java.lang.String value)
Bypass limit if the value of the provided header name matches the specified value.- Parameters:
name- The name of the header to check. This should match exactly with the header name in theHttpServletRequestcontext.value- The value to compare against. If the value of the header in the context matches this value, the limit will be bypassed.- Returns:
- Chainable builder
-
bypassLimitByAttribute
public ServletLimiterBuilder bypassLimitByAttribute(java.lang.String name, java.lang.String value)
Bypass limit if the value of the provided attribute name matches the specified value.- Parameters:
name- The name of the attribute to check. This should match exactly with the attribute name in theHttpServletRequestcontext.value- The value to compare against. If the value of the attribute in the context matches this value, the limit will be bypassed.- Returns:
- Chainable builder
-
bypassLimitByParameter
public ServletLimiterBuilder bypassLimitByParameter(java.lang.String name, java.lang.String value)
Bypass limit if the value of the provided parameter name matches the specified value.- Parameters:
name- The name of the parameter to check. This should match exactly with the parameter name in theHttpServletRequestcontext.value- The value to compare against. If the value of the parameter in the context matches this value, the limit will be bypassed.- Returns:
- Chainable builder
-
bypassLimitByPathInfo
public ServletLimiterBuilder bypassLimitByPathInfo(java.lang.String pathInfo)
Bypass limit if the request path info matches the specified path.- Parameters:
pathInfo- The path info to check against theHttpServletRequestpathInfo. If the request's pathInfo matches this, the limit will be bypassed.- Returns:
- Chainable builder
-
bypassLimitByMethod
public ServletLimiterBuilder bypassLimitByMethod(java.lang.String method)
Bypass limit if the request method matches the specified method.- Parameters:
method- The HTTP method (e.g. GET, POST, or PUT) to check against theHttpServletRequestmethod. If the request's method matches this method, the limit will be bypassed.- Returns:
- Chainable builder
-
self
protected ServletLimiterBuilder self()
- Specified by:
selfin classcom.netflix.concurrency.limits.limiter.AbstractLimiter.Builder<ServletLimiterBuilder>
-
-