Metadata-Version: 2.4
Name: ratelimiter_lite
Version: 0.1.4
Summary: Rate Limit Components
License: MIT
License-File: LICENSE.txt
Author: jackcizon
Author-email: jack20021213cn@gmail.com
Requires-Python: >=3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: dev
Requires-Dist: coverage (>=7.13.2,<8.0.0) ; extra == "dev"
Requires-Dist: mypy (>=1.19.1,<2.0.0) ; extra == "dev"
Requires-Dist: pre-commit (>=4.5.1,<5.0.0) ; extra == "dev"
Requires-Dist: pytest (>=9.0.2,<10.0.0) ; extra == "dev"
Requires-Dist: ruff (>=0.14.14,<0.15.0) ; extra == "dev"
Requires-Dist: sphinx (>=9.1.0,<10.0.0) ; extra == "dev"
Requires-Dist: sphinx-autobuild (>=2025.8.25,<2026.0.0) ; extra == "dev"
Description-Content-Type: text/x-rst

Rate Limit Components
==================================

.. image:: https://github.com/jackcizon/ratelimiter_lite/actions/workflows/ci.yaml/badge.svg
   :target: https://github.com/jackcizon/ratelimiter_lite/actions/workflows/ci.yaml/badge.svg
   :alt: CI


**version: 0.1.4**

.. code-block:: shell

   pip install ratelimiter_lite

Demo Usage:
----------------

.. code-block:: python

   import time
   from concurrent.futures.thread import ThreadPoolExecutor

   from ratelimiter_lite.factory import ratelimiter_lite_factory
   from ratelimiter_lite.fixed_window import FixedWindowratelimiter


   @ratelimiter_factory(FixedWindowratelimiter, limit=2, period=0.3)
   def task(args):
      print(f"task: {args}")


   def test_fixed_window():
      # limit worker count，observe ratelimiter_lite functions.
      with ThreadPoolExecutor(max_workers=5) as p:
         period = 2.0
         start = time.monotonic()
         while True:
               if time.monotonic() - start > period:
                  break

               p.submit(task, "running.")
               # wait thread for a while, the period should less than limiter's `period/limit`
               time.sleep(0.05)

