Expand description
PDK Rate Limit Library
Provides rate limiting functionality with support for both local and distributed storage backends.
It allows to control the rate at which operations can be performed by implementing token bucket algorithms with configurable limits and time windows.
Local mode handles all rate limiting quota in-memory, in a single node.
Clustered mode enables distributed rate limiting across multiple nodes, coordinating quota and statistics.
§Highlights
- Local and distributed rate limiting
- Configurable quota limits and time windows
- Support for grouped rate limits with selectors
- Asynchronous API for high-performance applications
§Primary types
RateLimit: trait which checks if a request should be allowed based on rulesRateLimitResult: result indicating if request is allowed or rejectedRateLimitStatistics: metadata about remaining quota and limitsRateLimitBuilder: instances builder with configurable options (e.g. clustering, custom buckets, distributed storage)RateLimitError: error type for rate limiting operations
Structs§
- Rate
Limit Builder - Builder pattern implementation for creating rate limit instances.
- Rate
Limit Builder Instance - A configurable instance of a rate limit builder.
- Rate
Limit Instance - An implementation of the RateLimit trait. For creating a new instance, use the
RateLimitBuilder. - Rate
Limit Statistics - Metadata about the remaining quota for a particular group and key pair.
Enums§
- Rate
Limit Error - Errors that can occur during rate limiting operations.
- Rate
Limit Result - This enum represents the result of a rate limit operation, indicating whether a request should be allowed or rejected based on the current rate limit state, along with statistics about the rate limit bucket.
Traits§
- Rate
Limit - RateLimit trait defines the core interface for rate limiting operations. Implementations can use different storage backends (local, distributed) and different algorithms while providing a consistent API.