Metadata-Version: 1.2
Name: python-throttle
Version: 0.1.6
Summary: Super naive python redis limiter
Home-page: https://github.com/soulomoon/python-throttle
Author: soulomoon
Author-email: fwy996602672@gmail.com
License: UNKNOWN
Description: `python version <https://pypi.python.org/pypi/python-throttle>`__ |Build
        Status| `codecov <https://codecov.io/gh/soulomoon/python-throttle>`__
        `PyPI version <https://badge.fury.io/py/python-throttle>`__
        
        python redis backed limiter
        ===========================
        
        sliding log or fixed window limiter
        -----------------------------------
        
        | This module mainly offer two limiter \* FixedWindowLimiter
        | simply using redis incr, which about 10 times the speed of the sliding
          version but the limit is not smooth, may overflow a threshold size
          near the gap between two intervals \* SlidingWindowLimiter  
        | using redis ordered set, slow but offers more smooth limit and more
          extendability
        
        installation
        ------------
        
        ``pip install python-throttle``
        
        dummy example usage:
        --------------------
        
        reminder: use name_space to avoid possible conflict on the same key
        
        .. code:: python
        
           import time
           from limiter import FixedWindowLimiter
           TEST_REDIS_CONFIG = {'host': 'localhost','port': 6379,'db': 10}
           ip = "who are you?"
           throttle = FixedWindowLimiter(threshold=2, interval=3, redis_config=TEST_REDIS_CONFIG, name_space="default")
           print("first time, blocked?: {}".format(throttle.exceeded(ip)))
           print("second time, blocked?: {}".format(throttle.exceeded(ip)))
           print("now I block you, blocked?: {}".format(throttle.exceeded(ip)))
           time.sleep(3)
           print("refill energy, blocked?: {}".format(throttle.exceeded(ip)))
        
        ouput:
        
        ::
        
           first time blocked?: False
           second time blocked?: False
           now I block you blocked?: True
           refill energy blocked?: False
        
        dummy beach mark
        ----------------
        
        It is from my unittest and not accurate,
        
        ::
        
           rate_counter_pressure_test: SlidingRedisCounter
           rate_counter_pressure_test: SlidingRedisCounter time count: 1.0075314449495636
           rate_counter_pressure_test: FixedWindowRedisCounter
           rate_counter_pressure_test: FixedWindowRedisCounter time count: 0.13711917598266155
        
        .. |Build Status| image:: https://travis-ci.org/soulomoon/python-throttle.svg?branch=develop
        
        
Keywords: throttle limiter redis counter timer middleware
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.4
