feat: capture HTTP Retry-After header in Error::retry_delay() for HttpStatus errors #21
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Error::retry_delay()(added in #19 / #20) only reads thegoogle.rpc.RetryInfodetail in a Vertex JSON error body. When a 429/503 arrives with a body that isn't Vertex JSON (for example from a proxy or gateway), the client returnsError::HttpStatus { status, body }. Response headers are thrown away when that error is built (src/client.rs, the non-JSON error path), so aRetry-Afterheader is lost.is_retryable()returnstrue, butretry_delay()returnsNone, so callers fall back to their own backoff and may retry too early.Proposed Changes
src/error.rs: add aretry_after: Option<std::time::Duration>field toError::HttpStatus(breaking changes are acceptable).src/client.rs: whereverError::HttpStatusis built, read theRetry-Afterheader before the body is consumed. Support the delay-seconds form (Retry-After: 30); the HTTP-date form is optional.Error::retry_delay(): returnretry_afterforHttpStatus.VertexError, fall back to the header when the body has noRetryInfo.src/client_tests.rsto cover a 429 withRetry-After: 30and a non-JSON body, a missing or invalid header, andretry_delay()for each case.