Liking cljdoc? Tell your friends :D
Clojure only.

congestion.limits


RateLimitcljprotocol

A RateLimit has to define a key, a quota, and a time-to-live.

The key is used to store the rate limit counter in storage. The returned key needs to be unique for each counter, eg an IP-based rate limit would include the IP-address of the client in the returned key so that each IP would have their own counter in storage.

The quota represents the number of requests that can be made withint the provided ttl.

The ttl (ie time-to-live) describes the timespan after which the rate limit is reset. Eg a rate limit with a ttl of 1s would be reset every second.

Note: all three fns take the incoming request as an argument. This allows the return values to be generated dynamically from the request. Eg an IP-based rate limit can lookup the :remote-addr from the request to generate the key. The main utility of this is in procuducing the key from the request, but it is also possible to use the request to dynamically generate quotas or ttls.

A RateLimit has to define a key, a quota, and a time-to-live.

The key is used to store the rate limit counter in storage. The
returned key needs to be unique for each counter, eg an IP-based
rate limit would include the IP-address of the client in the
returned key so that each IP would have their own counter in
storage.

The quota represents the number of requests that can be made withint
the provided ttl.

The ttl (ie time-to-live) describes the timespan after which the
rate limit is reset. Eg a rate limit with a ttl of 1s would be reset
every second.

Note: all three fns take the incoming request as an argument. This
allows the return values to be generated dynamically from the
request. Eg an IP-based rate limit can lookup the :remote-addr from
the request to generate the key. The main utility of this is in
procuducing the key from the request, but it is also possible to use
the request to dynamically generate quotas or ttls.

get-keyclj

(get-key self req)

get-quotaclj

(get-quota self req)

get-ttlclj

(get-ttl self req)
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close