Skip to main content

Python Rate-Limiter using Leaky-Bucket Algorimth Family

Project description

Request Rate Limiter using Leaky-bucket algorimth

Introduction

This module can be used to apply rate-limit for API request, using leaky-bucket algorimth. User defines window duration and the limit of function calls within such interval.

Currently this package requires Redis to work with.

Installation

$ pip install pyrate-limiter

Usage

from pyrate_limiter.core import RedisBucket as Bucket, HitRate

# Init bucket singleton
bucket = Bucket('redis-url', prefix='redis-prefix')

# Init rate_limiter
limiter = HitRate(
    bucket,
    capacity=10,
    interval=60,
)

# Use as decorator
@limiter('redis-key')
def call(*args, **kwargs):
    pass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrate-limiter-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrate_limiter-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pyrate-limiter-0.1.0.tar.gz.

File metadata

  • Download URL: pyrate-limiter-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.5 Darwin/18.7.0

File hashes

Hashes for pyrate-limiter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d98a5b8ffd41841caf647dcb138e32782c2c36d6a11ad9cbfacbcffa84eb0ace
MD5 a5b72a3e82982da587a1ce0876f6a508
BLAKE2b-256 341a530ee95ed820dd11d15e53b4c0f6657b7a205d21e40d901b4f374251da45

See more details on using hashes here.

File details

Details for the file pyrate_limiter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyrate_limiter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.5 Darwin/18.7.0

File hashes

Hashes for pyrate_limiter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccc510d65f960b4a0eaeab0046f7618bdb6adb4e39b398477bb44b839c72f069
MD5 75d263ec3e7e92c2786c36faf8bdca78
BLAKE2b-256 f2b979e2575c3e0c9c5734a6dbeff6b9c1bb85e8c524f87a9d109e02b6ee641d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page