Changelog

This library adheres to Semantic Versioning 2.0.

Unreleased

Nothing changed yet.

4.1.1

A RuntimeError is now raised when entering context managers more than once, for objects for which it would cause undefined behavior. Impacted classes are the following:

  • Buckets:

    • FixedWindowCounter

    • LeakyBucket

    • SlidingWindowLog

    • BucketGroup

  • Rate Controllers (not considering the underlying buckets):

    • Scheduler

The __slots__ attribute was removed from all buckets and rate controllers, for practical reasons.

4.1.0

  • Added the NoopController controller, that simply lets requests through.

  • Improved the performance of the Scheduler by better detecting availability conditions for queued requests, thus no longer requiring an internal lock.

4.0.0

  • Breaking change: Mixin helper methods were moved away from the RateController abstract class.

  • Breaking change: Now define __slots__ in all classes for better memory management

3.0.1

  • Allow passing kwargs in abstract RateController.request(...).

3.0.0

  • Now allow passing no bucket argument to the rate controllers.

  • Breaking change: Removed the now obsolete UnlimitedBucket.

2.0.0

Breaking changes

  • Unified the API for the rate controllers.

    • Now both the RateLimiter and the Scheduler use the following signature: async with controller.request(tokens): ...

    • The RateLimiter can now also be instantiated in an async with RateLimiter(...) statement.

  • Rate controllers now manage their bucket’s context in their async with statement, so that we don’t need to enter manually the bucket’s context and then the rate controller’s context. This behavior can be disabled using the should_enter_context flag in the constructor.

  • The rate_control.buckets module is now private. The RateController base class, and all buckets, are now exported in the main rate_control module.

New Features

  • The BucketGroup class now implements the Iterable[Bucket] protocol.

1.1.0

Added the ability to update the token capacity for FixedWindowCounter and SlidingWindowLog.

1.0.0

First release of the project