falcon-ratelimit
================
Rate limiter for Falcon. Install with:
pip install falcon-ratelimit
Use like:
import falcon
from falconratelimit import rate_limit
class NoRedisResource(object):
@falcon.before(rate_limit(per_second=5, window_size=30,
resource='resource_name'))
def on_post(self, req, resp):
...
class RedisResource(object):
@falcon.before(rate_limit(redis_url='localhost:6379', per_second=1,
window_size=10))
def on_post(self, req, resp):
...
This package works by limiting the number of requests using two variables
per_second and window_size. In the first example above, the
NoRedisResource class is restricted to 5 requests per second over a 30 second
window meaning that there is a limit of 150 requests over 30 seconds. The
default storage of calling the rate_limit decorator is an in memory list to
store the number of requests for the given user using the resource
resource_name.
The second example implements the optional storage to use Redis by passing in a
redis_url to store user request data. Using Redis allows for the rate
limiting to be implemented across multiple instances of a particular
application. In the RedisResource class example the user is allowed to make
1 request per second over 10 seconds meaning that there is a limit of 10
requests over 10 seconds. Since this example didn't pass in a resource it
uses default as the name for request storage.
If you do not have the redis package installed, Redis-related functionality
will not work.
Release files for falcon-ratelimit 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| falcon-ratelimit-1.2.tar.gz | 3.8 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| falcon_ratelimit-1.2-py3.8.egg | Legacy Egg format | - | - | Details |
| falcon_ratelimit-1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.6 kB
Release files / falcon-ratelimit-1.2.tar.gz
| Download URL | falcon-ratelimit-1.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b67b1be7c975b76bf8c6e594afe937193b09fee7b528667075c2a074f2c5cf4a
|
|
BLAKE2b-256 checksum How to use checksums |
8b37f58de70a609c9c3ca2f96e73d5eaab153efd26d0970f849f14922b075edd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0
|
Release files / falcon_ratelimit-1.2-py3.8.egg
| Download URL | falcon_ratelimit-1.2-py3.8.egg |
|---|---|
| Size | 3.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
9c97f8995cd5a2fc46194fc3284c2336e9858ae1533f0f655f73912d81aa983f
|
|
BLAKE2b-256 checksum How to use checksums |
42fcf08462c5d8a785973e14c1f25a0c47f136ff6d7cc0a75acf5c9350414fcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0
|
Release files / falcon_ratelimit-1.2-py2.py3-none-any.whl
| Download URL | falcon_ratelimit-1.2-py2.py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
d732531d9baf9d75fd7259d7670f192b836a90e8805491a42846f1c145c68ecc
|
|
BLAKE2b-256 checksum How to use checksums |
c3ceb78adc0d98c95d306bc093991c7531334fb7e2f9d8cb6a9cfc4e1bb68ae7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0
|