Skip to main content

Module rate_limit

Module rate_limit 

Source
Expand description

Shared Actix rate-limit building blocks.

This module keeps product-neutral rate-limit mechanics in Forge while leaving product response envelopes and protocol-specific error bodies in application crates. It provides:

  • a trusted-proxy-aware IP key extractor for actix-governor;
  • small quota helpers for building Actix governor configs from non-zero (seconds_per_request, burst_size) pairs;
  • a keyed string limiter for protocol endpoints that rate-limit by usernames, emails, or other normalized business keys.

Structs§

NormalizedStringRateLimiter
A keyed string rate limiter with product-neutral key normalization.
RateLimitRejection
Product-neutral rate-limit rejection metadata.
TrustedProxyIpKeyExtractor

Functions§

build_ip_governor_config
Builds an Actix governor config using the trusted-proxy-aware IP extractor.
build_ip_governor_config_with_rejection_response
Builds an Actix governor config with a product-provided rejection response.
retry_after_seconds
Returns the retry delay in whole seconds for a governor rejection.