Available on crate feature
retry only.Expand description
Retries for HTTP APIs: RetryPolicy, a tower retry policy, and RetryLayer, which adds to it a look at the
body of a 429 to tell a rate limit (retried) from an exhausted quota (not retried).
Client::default() already retries with RetryLayer::new(RetryPolicy::default()). For another policy, start from
the bare service:
use timvw_rust_runtime::retry::{self, RetryLayer, RetryPolicy};
use timvw_rust_runtime::{Client, ReqwestService};
let client = Client::from_service(ReqwestService::default())
.layer(RetryLayer::new(RetryPolicy::new(5)).permanent_429(retry::openai_insufficient_quota));Structs§
- Classify429
- The service inside the retries of a
RetryLayer: marks a429Permanentwhen its body says so. - Permanent
- A response extension that tells
RetryPolicynot to retry a response it would otherwise retry. - Retry
Layer - Retries with a
RetryPolicy, and optionally reads the body of a429to tell a permanent error from a rate limit first. - Retry
Policy - Retries
429 Too Many Requests,408 Request Timeoutand5xxresponses, and failures to connect.
Constants§
- DEFAULT_
BODY_ LIMIT - How much of a
429bodyRetryLayerreads by default to classify it: 64 KiB.
Functions§
- openai_
insufficient_ quota - OpenAI’s “quota exhausted”: a JSON body whose
error.codeorerror.typeisinsufficient_quota.