Metadata-Version: 2.4
Name: kanicounter
Version: 0.1.0
Summary: Count events in rolling time windows and raise when limits are exceeded.
Home-page: 
Author: fx-kirin
Author-email: fx.kirin@gmail.com
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

kanicounter
===========

``kanicounter`` is a small Python library for counting events in rolling time
windows. It raises an exception when an event exceeds the allowed count.

Usage
-----

.. code-block:: python

    from kanicounter import EventCounter, EventLimitError

    counter = EventCounter()
    counter.add_watch_window(seconds=60, limit=10)

    try:
        counter.add_event()
    except EventLimitError as exc:
        print(exc)

``limit`` is the number of events allowed inside the window. For example,
``seconds=60, limit=10`` allows 10 events in the last 60 seconds and raises
``EventLimitError`` on the 11th event.

Installation
------------

.. code-block:: console

    pip install kanicounter

Requirements
------------

Python 3.8 or newer. There are no runtime dependencies.

Licence
-------

MIT

Authors
-------

``kanicounter`` was written by `fx-kirin <mailto:fx.kirin@gmail.com>`_.
