Class MappedThrottlingPolicyHeaplet
java.lang.Object
org.forgerock.openig.heap.GenericHeaplet
org.forgerock.openig.filter.throttling.MappedThrottlingPolicyHeaplet
- All Implemented Interfaces:
Heaplet
Creates and initializes a
MappedThrottlingPolicy
in a heap environment.
Configuration options:
{
"type": "MappedThrottlingPolicy",
"config": {
"throttlingRateMapper" : expression<String> [REQUIRED - The expression that will be
evaluated to lookup for a
throttling rate.]
"throttlingRatesMapping" : { [REQUIRED - This is a in memory map used to
lookup the throttling rate to
apply.]
"<throttlingRateKey>" { : String [REQUIRED - The value to match the
result of the expression
throttlingRateMapper.]
"numberOfRequests" : integer [REQUIRED - The number of requests allowed
to go through this filter during
the duration window.]
"duration" : duration [REQUIRED - The time window during which the
incoming requests are counted.]
}
},
"defaultRate" { : reference [OPTIONAL - the default rate to apply if
there is no match]
"numberOfRequests" : integer [REQUIRED - The number of requests allowed
to go through this filter during
the duration window.]
"duration" : duration [REQUIRED - The time window during which the
incoming requests are counted.]
}
}
}
Example : apply different throttling rates depending of the header 'Origin'. If the header is not specified, let's
apply a default rate of 15 requests per second.
{
"type": "MappedThrottlingPolicy",
"config": {
"throttlingRateMapper" : "${request.headers['Origin'][0]}"
"throttlingRateMapping" : {
"http://www.alice.com" : {
"numberOfRequests" : 30,
"duration" : "1 hour"
},
"http://www.bob.com" : {
"numberOfRequests" : 42,
"duration" : "1 minute"
}
},
"defaultRate" : {
"numberOfRequests" : 15,
"duration" : "1 sec"
}
}
}
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.forgerock.openig.heap.GenericHeaplet
create, destroy, endpointRegistry, evaluatedWithHeapProperties, expression, getConfig, getHeap, getType, initialBindings, meterRegistryHolder, start
-
Constructor Details
-
MappedThrottlingPolicyHeaplet
public MappedThrottlingPolicyHeaplet()
-
-
Method Details
-
create
Description copied from class:GenericHeaplet
Called to request the heaplet create an object. Called byHeaplet.create(Name, JsonValue, Heap)
after initializing the protected field members. Implementations should parse configuration but not acquire resources, start threads, or log any initialization messages. These tasks should be performed by theGenericHeaplet.start()
method.- Specified by:
create
in classGenericHeaplet
- Returns:
- The created object.
- Throws:
HeapException
- if an exception occurred during creation of the heap object or any of its dependencies.
-