HTTP client with sane defaults
Use this starter when you need a basic HTTP client policy with explicit bounds, predictable retry behavior, and low-cardinality observability.
import httpx
from redress import Policy, Retry, default_classifier
from redress.contrib.httpx import RetryingHttpxClient, default_result_classifier
from redress.strategies import decorrelated_jitter, retry_after_or
policy = Policy(
retry=Retry(
classifier=default_classifier,
result_classifier=default_result_classifier,
strategy=retry_after_or(decorrelated_jitter(max_s=5.0)),
max_attempts=4,
deadline_s=10.0,
max_unknown_attempts=2,
),
)
with httpx.Client(timeout=3.0, base_url="https://api.example.com") as client:
upstream = RetryingHttpxClient(client, policy)
response = upstream.get("/users/123")
Why these defaults:
deadline_s=10.0keeps the failure envelope boundedmax_attempts=4is enough for transient recovery without long tailsdefault_result_classifierhandles common HTTP response retry casesretry_after_or(...)respectsRetry-Afterwhen presentmax_unknown_attempts=2keeps broad unknown failures conservative
For the core API surface, see Usage. For more HTTP-specific patterns, see HTTP recipes.