Skip to main content

Module retry

Module retry 

Source
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 a 429 Permanent when its body says so.
Permanent
A response extension that tells RetryPolicy not to retry a response it would otherwise retry.
RetryLayer
Retries with a RetryPolicy, and optionally reads the body of a 429 to tell a permanent error from a rate limit first.
RetryPolicy
Retries 429 Too Many Requests, 408 Request Timeout and 5xx responses, and failures to connect.

Constants§

DEFAULT_BODY_LIMIT
How much of a 429 body RetryLayer reads by default to classify it: 64 KiB.

Functions§

openai_insufficient_quota
OpenAI’s “quota exhausted”: a JSON body whose error.code or error.type is insufficient_quota.