public class MappedThrottlingPolicyHeaplet extends GenericHeaplet
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"
}
}
}
Constructor and Description |
---|
MappedThrottlingPolicyHeaplet() |
Modifier and Type | Method and Description |
---|---|
Object |
create()
Called to request the heaplet create an object.
|
create, destroy, endpointRegistry, evaluatedWithHeapProperties, expression, start
public Object create() throws HeapException
GenericHeaplet
Heaplet.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 the GenericHeaplet.start()
method.create
in class GenericHeaplet
HeapException
- if an exception occurred during creation of the heap object
or any of its dependencies.Copyright © 2025 Open Identity Platform Community. All rights reserved.