Class MappedThrottlingPolicy
- java.lang.Object
-
- org.forgerock.openig.filter.throttling.MappedThrottlingPolicy
-
- All Implemented Interfaces:
ThrottlingPolicy
public class MappedThrottlingPolicy extends Object implements ThrottlingPolicy
Implementation ofThrottlingPolicy
backed by aMap
.- if the key is null, then the
defaultRate
is returned - if the key can be looked up as key in the
throttlingRatesMapping
, then the matching rate is returned - if the key can't be looked up in the
throttlingRatesMapping
, then thedefaultRate
is returned
-
-
Constructor Summary
Constructors Constructor Description MappedThrottlingPolicy(AsyncFunction<ContextAndRequest,String,Exception> throttlingRateMapper, Map<String,ThrottlingRate> throttlingRatesMapping, ThrottlingRate defaultRate)
Constructs a newMappedThrottlingPolicy
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<ThrottlingRate,Exception>
lookup(Context context, Request request)
Returns theThrottlingRate
that should be used for the provided request.
-
-
-
Constructor Detail
-
MappedThrottlingPolicy
public MappedThrottlingPolicy(AsyncFunction<ContextAndRequest,String,Exception> throttlingRateMapper, Map<String,ThrottlingRate> throttlingRatesMapping, ThrottlingRate defaultRate)
Constructs a newMappedThrottlingPolicy
.- Parameters:
throttlingRateMapper
- the key to lookup the throttling ratethrottlingRatesMapping
- the Map to look into to find the matching throttling rate.defaultRate
- the default throttling definition.
-
-
Method Detail
-
lookup
public Promise<ThrottlingRate,Exception> lookup(Context context, Request request)
Description copied from interface:ThrottlingPolicy
Returns theThrottlingRate
that should be used for the provided request.- Specified by:
lookup
in interfaceThrottlingPolicy
- Parameters:
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.- Returns:
- A
Promise
representing theThrottlingRate
that should be used for the request.
-
-