carbond.limiter.LimiterPolicy¶
LimiterPolicy is used to define some policy over
requests to a particular endpoint based on some key representing a request
(e.g., as extracted by an accompanying instance of
LimiterSelector) and some historical context.
Class¶
-
class
carbond.limiter.LimiterPolicy()¶ abstract
sharedState BooleanRequired Default falseDescription If true,statewill be shared with any otherPolicyLimiterthat also indicates it wants to share state.
- ¶
stateKey StringDescription This is a read-only attribute used to lookup the state object for a LimiterPolicyinstance.
- ¶
state Description This is a read-only attribute that holding a pointer to the state object associated with this policy.
- ¶
initializeState Arguments - state – a shared
LimiterPolicyStateinstance orundefined
Description Called on initialization. Sets and/or gets the policy state. - state – a shared
- ¶
allow Arguments - req (
express.request) – the currentRequestobject - res (
express.response) – the currentResponseobject - selector (
String) – A string used to group similar requests
Returns trueif the policy allows the request, elsefalseReturn type BooleanDescription abstract Description This method should be overridden to evaluate the current request as identified by selectorin the context ofstateand decide whether or not it should be allowed.- req (