carbond.limiter.Limiter¶
Limiter is an abstract base class that all other
limiters must extend. Generally, you will want to use
FunctionLimiter or
PolicyLimiter to implement a custom limiter.
However, if neither of these suites your needs, you can define your own limiter
class by extending this.
XXX - EXAMPLES:
Link to TooBusyLimiter class: TooBusyLimiter
Link to TooBusyLimiter class with full class name: carbond.limiter.TooBusyLimiter
Link to TooBusyLimiter.absMaxOutstandingReqs: absMaxOutstandingReqs
Link to TooBusyLimiter.absMaxOutstandingReqs with full attribute name: carbond.limiter.TooBusyLimiter.absMaxOutstandingReqs
Link to TooBusyLimiter.fn: fn
Class¶
-
class
carbond.limiter.Limiter() abstract
- ¶
service Required Description The root service instance.
- ¶
node Required Description The endpoint instance that this limiter is protecting (NOTE, this can be the same as service).
- ¶
preAuth BooleanRequired Default falseDescription Determines whether this limiter is invoked before or after authentication. (NOTE: if you are using ReqPropertyLimiterSelectorand you want to check user info, you will want to
Methods¶
- ¶
initialize Arguments - service (
Service) – the rootServiceinstance - node (
carbond.Endpoint) – theEndpointthat we are attached to
Description Called on service initialization. Sets the serviceandnodeattributes.- service (
- ¶
process Arguments - req (
express.request) – the currentRequestobject - res (
express.response) – the currentResponseobject - next (
Function) – continuation
Description abstract Description Subclasses must override this method and ensure that the request-response cycle is ended or nextis called (with or without an error).- req (
sendUnavailable Arguments - res (
express.response) – the currentResponseobject - message (
String) – any other message you want to bubble up to the client - retryAfter (
Integer) – hint to the client as to when to retry the request (in seconds)
Description Sends a 503back to the client.Description TODO: 429s should also be supported.- res (