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 Boolean
Required Default false
Description If true
,state
will be shared with any otherPolicyLimiter
that also indicates it wants to share state.
- ¶
stateKey String
Description This is a read-only attribute used to lookup the state object for a LimiterPolicy
instance.
- ¶
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
LimiterPolicyState
instance orundefined
Description Called on initialization. Sets and/or gets the policy state. - state – a shared
- ¶
allow Arguments - req (
express.request
) – the currentRequest
object - res (
express.response
) – the currentResponse
object - selector (
String
) – A string used to group similar requests
Returns true
if the policy allows the request, elsefalse
Return type Boolean
Description abstract Description This method should be overridden to evaluate the current request as identified by selector
in the context ofstate
and decide whether or not it should be allowed.- req (