Skip to main content

Module ratelimit

Module ratelimit 

Source
Expand description

Per-host rate limiting and concurrency control Per-host rate limiting and concurrency control.

This module provides adaptive rate limiting for HTTP requests on a per-host basis. It prevents overwhelming servers with too many concurrent requests and respects server-provided rate limit headers.

Β§Architecture

  • [HostKey]: Represents a hostname/domain for rate limiting
  • [Host]: Manages rate limiting, concurrency, and caching for a specific host
  • [HostPool]: Coordinates multiple hosts and routes requests appropriately
  • [HostConfig]: Configuration for per-host behavior
  • [HostStats]: Statistics tracking for each host

ModulesΒ§

config πŸ”’
headers πŸ”’
Handle rate limiting headers. Note that we might want to replace this module with https://github.com/mre/rate-limits at some point in the future.
host πŸ”’
pool πŸ”’

StructsΒ§

CacheableResponse πŸ”’
The result of a HTTP request, used for internal per-host caching. This abstraction exists, because Response cannot easily be cached since it does not implement Clone.
Host
Represents a single host with its own rate limiting, concurrency control, HTTP client configuration, and request cache.
HostConfig
Configuration for a specific host’s rate limiting behavior
HostConfigs
Per-host configuration overrides
HostKey
A type-safe representation of a hostname for rate limiting purposes.
HostPool
Manages a pool of Host instances and routes requests to appropriate hosts.
HostStats
Record and report statistics for a crate::ratelimit::Host
HostStatsMap
A HashMap mapping hosts to their HostStats
RateLimitConfig
Global rate limiting configuration that applies as defaults to all hosts

Type AliasesΒ§

ClientMap
Keep track of host-specific reqwest::Clients