feat(tonic-xds): add transport-generic build_transport_channel - #2785
Closed
LYZJU2019 wants to merge 1 commit into
Closed
feat(tonic-xds): add transport-generic build_transport_channel#2785LYZJU2019 wants to merge 1 commit into
LYZJU2019 wants to merge 1 commit into
Conversation
Add `XdsChannelBuilder::build_transport_channel`, a transport-generic build path that wires the xDS routing -> retry -> load-balancing stack over a caller-provided `MakeConnector` and returns a type-erased, cloneable `Send + Sync` tower service. The gRPC channel becomes the special case of this shared stack. Refactor channel.rs to share a single private `build_stack` core between the gRPC and generic paths, and extract `load_bootstrap` / `build_xds_runtime` helpers. The cert-provider registry stays gRPC-only. Make the retry seam public so non-gRPC transports can plug their own retry logic: `RetryClassifier`, `RetryConfig`, `RetryBackoffConfig`, and `is_retryable_connection_error`. Retry behavior is threaded into `build_transport_channel` as a classifier + config; the internal `RetryPolicy` stays private. Allowlist `shared_http_body` for check-external-types: the caller's connector accepts a `SharedBody`-wrapped body so requests can be cloned for retries.
Contributor
Author
|
Superseded by #2786, which reworks the retry configuration to be control-plane-driven: instead of a static |
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.
What
Adds
XdsChannelBuilder::build_transport_channel, a transport-generic build path that wires the xDS routing → retry → load-balancing stack over a caller-providedMakeConnectorand returns a type-erased, cloneableSend + Synctower::Service. The existing gRPC channel becomes the special case of this shared stack.This is an additive, non-breaking change — no existing public API changes behavior, and the gRPC connect path and all gRPC tests are untouched.
Why
Follow-up to the xDS transport-generalization work (#2750, #2751, #2776). Downstream users that speak a non-gRPC transport (e.g. plain HTTP) need to drive the same xDS routing/retry/LB machinery with their own per-endpoint connector, without reimplementing the stack.
Details
build_stackthat both the gRPC and generic paths call; the gRPC path (build_from_cache) is now a thin caller. Also extractedload_bootstrap/build_xds_runtimehelpers. The cert-provider registry stays gRPC-only (built before the bootstrap node is consumed, so the generic path never pays for it).Request<B>→Request<SharedBody<B>>so a request can be cloned for replay; apost_retry_mapbridges back to the body the per-endpoint service expects. gRPC rewraps into atonicbody (unchanged); the generic path's connector acceptsSharedBody<B>directly (identity map).RetryClassifier,RetryConfig,RetryBackoffConfig, andis_retryable_connection_errorpublic so non-gRPC transports can plug their own retry logic. Retry behavior is threaded intobuild_transport_channelas aclassifier+RetryConfig; the internalRetryPolicy(and itstower::retry::Policyimpl) stays private to keep the public surface minimal.shared_http_body— the caller's connector accepts aSharedBody-wrapped body.Testing
xds_channel_e2e_transport_generic_routes_to_backend) drives the generic path end-to-end through the mock control plane, using a customRetryClassifier+ aSharedBody-accepting connector written entirely against the public API.-D warnings(400 tests + 4 doctests), clippy, rustfmt, andcheck-external-types --all-featuresall pass.