Class MappedThrottlingPolicy
- java.lang.Object
-
- org.forgerock.openig.filter.throttling.MappedThrottlingPolicy
-
- All Implemented Interfaces:
ThrottlingPolicy
public class MappedThrottlingPolicy extends Object implements ThrottlingPolicy
Implementation ofThrottlingPolicybacked by aMap.- if the key is null, then the
defaultRateis 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 thedefaultRateis 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 theThrottlingRatethat 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:ThrottlingPolicyReturns theThrottlingRatethat should be used for the provided request.- Specified by:
lookupin 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
Promiserepresenting theThrottlingRatethat should be used for the request.
-
-