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
Boolean
Required
Default false
Description Determines whether this limiter is invoked before or after authentication. (NOTE: if you are using ReqPropertyLimiterSelector and you want to check user info, you will want to

Methods

initialize  
Arguments
Description Called on service initialization. Sets the service and node attributes.
process  
Arguments
  • req (express.request) – the current Request object
  • res (express.response) – the current Response object
  • next (Function) – continuation
Description abstract
Description Subclasses must override this method and ensure that the request-response cycle is ended or next is called (with or without an error).
sendUnavailable  
Arguments
  • res (express.response) – the current Response object
  • 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 503 back to the client.
Description TODO: 429 s should also be supported.

Example