B - type of the bucket used to differentiate clientspublic class Throttler<B> extends Object
| Modifier and Type | Field and Description |
|---|---|
String |
alwaysThrottleParam
This parameter in query will cause throttling no matter what.
|
| Constructor and Description |
|---|
Throttler(Duration requestTimeThreshold,
Bucketing<B> bucketing,
Callable<ThrottlingState> createThrottlingState,
com.google.common.cache.Cache<B,ThrottlingState> stateStore,
String enableThrottlingIfHeader,
String alwaysThrottleParam)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
failure(javax.servlet.http.HttpServletRequest request,
Duration elapsed)
Notify this throttler that a request has completed in error.
|
Duration |
getBackoffDelay(javax.servlet.http.HttpServletRequest request)
How long should this client wait before his next request.
|
long |
getStateSize()
The size (in number of entries) of the throttling state.
|
boolean |
isThrottled(javax.servlet.http.HttpServletRequest request)
Should this request be throttled.
|
void |
success(javax.servlet.http.HttpServletRequest request,
Duration elapsed)
Notify this throttler that a request has been completed successfully.
|
public final String alwaysThrottleParam
public Throttler(Duration requestTimeThreshold, Bucketing<B> bucketing, Callable<ThrottlingState> createThrottlingState, com.google.common.cache.Cache<B,ThrottlingState> stateStore, String enableThrottlingIfHeader, String alwaysThrottleParam)
requestTimeThreshold - requests longer than this will trigger
tracking resource consumptionbucketing - how to associate a request with a specific bucketcreateThrottlingState - how to create the initial throttling state
when we start tracking a specific clientstateStore - the cache in which we store the per client state of
throttlingenableThrottlingIfHeader - throttling is only enabled if this header is presentalwaysThrottleParam - this query parameter will cause throttling no matter whatpublic long getStateSize()
public boolean isThrottled(javax.servlet.http.HttpServletRequest request)
request - the request to checkpublic void success(javax.servlet.http.HttpServletRequest request,
Duration elapsed)
request - the requestelapsed - how long that request tookpublic void failure(javax.servlet.http.HttpServletRequest request,
Duration elapsed)
request - the requestelapsed - how long that request tookpublic Duration getBackoffDelay(javax.servlet.http.HttpServletRequest request)
request - the requestCopyright © 2018. All rights reserved.