public class MappedThrottlingPolicy extends Object implements ThrottlingPolicy
ThrottlingPolicy
backed by a Map
.
defaultRate
is returnedthrottlingRatesMapping
, then the matching rate is returned
throttlingRatesMapping
, then the defaultRate
is returned
Constructor and Description |
---|
MappedThrottlingPolicy(AsyncFunction<ContextAndRequest,String,Exception> throttlingRateMapper,
Map<String,ThrottlingRate> throttlingRatesMapping,
ThrottlingRate defaultRate)
Constructs a new
MappedThrottlingPolicy . |
Modifier and Type | Method and Description |
---|---|
Promise<ThrottlingRate,Exception> |
lookup(Context context,
Request request)
Returns the
ThrottlingRate that should be used for the provided request. |
public MappedThrottlingPolicy(AsyncFunction<ContextAndRequest,String,Exception> throttlingRateMapper, Map<String,ThrottlingRate> throttlingRatesMapping, ThrottlingRate defaultRate)
MappedThrottlingPolicy
.throttlingRateMapper
- the key to lookup the throttling ratethrottlingRatesMapping
- the Map to look into to find the matching throttling rate.defaultRate
- the default throttling definition.public Promise<ThrottlingRate,Exception> lookup(Context context, Request request)
ThrottlingPolicy
ThrottlingRate
that should be used for the provided request.lookup
in interface ThrottlingPolicy
context
- The current context which might be used to retrieve the throttling rate.request
- The current request which might be used to retrieve the throttling rate.Promise
representing the ThrottlingRate
that should be used for the request.Copyright 2011-2017 ForgeRock AS.