proxywhirl.retry.policy¶
Retry policy configuration and backoff strategies.
Classes¶
Retry backoff timing strategy. |
|
Configuration for retry behavior. |
Module Contents¶
- class proxywhirl.retry.policy.BackoffStrategy[source]¶
-
Retry backoff timing strategy.
Initialize self. See help(type(self)) for accurate signature.
- class proxywhirl.retry.policy.RetryPolicy(/, **data)[source]¶
Bases:
pydantic.BaseModelConfiguration for retry behavior.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- calculate_delay(attempt, previous_delay=None)[source]¶
Calculate delay for given attempt number (0-indexed).
Uses AWS decorrelated jitter algorithm when jitter is enabled to prevent the thundering herd problem. The decorrelated jitter ensures that retry delays depend on previous delay values, spreading retries across time.
- AWS decorrelated jitter formula:
delay = min(cap, random(base, previous_delay * 3))
Reference: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
- Parameters:
- Returns:
Delay in seconds before the next retry attempt
- Return type: