betty.http_client.rate_limit module¶
HTTP client rate limiting.
- final class betty.http_client.rate_limit.RateLimitDefinition¶
Bases:
OrderedPluginDefinitionThe http client rate limit plugin type. Rate limits ensure that Betty’s HTTP client does not make more requests to a web service than that service supports or allows, by enforcing a maximum number of requests per timeframe.
Plugin type ID
http-rate-limitDefinition
Built-in http client rate limits:
- __init__(plugin_id: ResolvableMachineName, *, limit: tuple[int, int], match: str | re.Pattern, auto: bool = True, after: Order[RateLimitDefinition] = (), before: Order[RateLimitDefinition] = (), requires: Requires = ())¶
- property limit: tuple[int, int]¶
The limit expressed as a 2-tuple of the maximum and the period (in seconds).
- static type() PluginTypeDefinition[Self]¶
The plugin type definition.
- final class betty.http_client.rate_limit.RateLimitMiddleware¶
Bases:
objectHTTP client middleware to rate-limit requests.
This is thread-safe, which means you can safely use this between different threads.
- __init__(limits: Iterable[RateLimitDefinition], /)¶