refactor(tonic-xds): extract transport-agnostic RetryClassifier seam#2750
Open
LYZJU2019 wants to merge 1 commit into
Open
refactor(tonic-xds): extract transport-agnostic RetryClassifier seam#2750LYZJU2019 wants to merge 1 commit into
LYZJU2019 wants to merge 1 commit into
Conversation
Split the retry layer into a transport-agnostic decision engine and a
transport-specific classifier so non-gRPC transports (e.g. plain HTTP)
can reuse the same retry machinery without duplicating a state machine.
- Add `RetryClassifier` trait: `is_retryable` decides retryability from
the response/error; a default-noop `prepare_retry` allows per-retry
request mutation.
- Add `GrpcRetryClassifier { retry_on }` implementing the previous gRPC
behavior verbatim (retryable connection error or retryable grpc-status,
plus stamping the `grpc-previous-rpc-attempts` header).
- Generalize `GrpcRetryPolicy` into `RetryPolicy<C>` holding the shared
decision state (attempt cap, backoff, body cloning) behind `ArcSwap`
and delegating transport decisions to the classifier. Tower's `Retry`
service still owns the retry state machine.
- Rename `GrpcRetryPolicyConfig` -> `RetryConfig` (retry_on moved to the
classifier) and `GrpcRetryBackoffConfig` -> `RetryBackoffConfig`.
- Keep `GrpcRetryPolicy = RetryPolicy<GrpcRetryClassifier>` as an alias
so existing callers are unchanged.
Items remain crate-internal (`pub(crate)`); public re-exports are
deferred to the transport-API step. Behavior is unchanged.
LYZJU2019
force-pushed
the
lyzju2019/xds-retry-classifier-seam
branch
from
July 24, 2026 23:08
5235089 to
79eeee0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the
tonic-xdsclient retry layer to be transport-agnostic so non-gRPC transports (e.g. plain HTTP) can reuse the same retry engine without duplicating a retry state machine. This is a non-breaking, standalone change: all items stay crate-internal (pub(crate)) and the existing gRPC behavior is preserved.Why
First step of generalizing the xDS retry layer so it can serve both gRPC and HTTP transports. Keeping the gRPC-specific logic (retryable codes +
grpc-previous-rpc-attemptsheader) behind the classifier keepstonic-xdstransport-agnostic while leaving gRPC the default.Testing
cargo build -p tonic-xds— clean (no warnings)cargo test -p tonic-xds— 340 passed, 0 failed (incl. retry unit tests +test_retry_once_on_unavailable)cargo clippy -p tonic-xds --all-targets— no new warnings in changed filescargo doc -p tonic-xds --no-deps(withRUSTDOCFLAGS=-D warnings) — cleanBehavior is unchanged; the diff is behavior-preserving.