Skip to main content

Crate pdk_rate_limit_lib

Crate pdk_rate_limit_lib 

Source
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 rules
  • RateLimitResult: result indicating if request is allowed or rejected
  • RateLimitStatistics: metadata about remaining quota and limits
  • RateLimitBuilder: instances builder with configurable options (e.g. clustering, custom buckets, distributed storage)
  • RateLimitError: error type for rate limiting operations

Structs§

RateLimitBuilder
Builder pattern implementation for creating rate limit instances.
RateLimitBuilderInstance
A configurable instance of a rate limit builder.
RateLimitInstance
An implementation of the RateLimit trait. For creating a new instance, use the RateLimitBuilder.
RateLimitStatistics
Metadata about the remaining quota for a particular group and key pair.

Enums§

RateLimitError
Errors that can occur during rate limiting operations.
RateLimitResult
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§

RateLimit
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.