B - type of the bucket used to differentiate clientspublic class Throttler<B> extends Object
| Constructor and Description |
|---|
Throttler(Duration requestTimeThreshold,
Bucketing<B> bucketing,
Callable<ThrottlingState> createThrottlingState,
com.google.common.cache.Cache<B,ThrottlingState> stateStore,
String enableThrottlingIfHeader)
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.
|
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 Throttler(Duration requestTimeThreshold, Bucketing<B> bucketing, Callable<ThrottlingState> createThrottlingState, com.google.common.cache.Cache<B,ThrottlingState> stateStore, String enableThrottlingIfHeader)
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 present.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 © 2017. All rights reserved.