Skip to content

feat(tonic-xds): implement xds resources and route matchers#2533

Merged
YutaoMa merged 10 commits intohyperium:masterfrom
YutaoMa:yutaoma/grpc-xds-layers
Mar 17, 2026
Merged

feat(tonic-xds): implement xds resources and route matchers#2533
YutaoMa merged 10 commits intohyperium:masterfrom
YutaoMa:yutaoma/grpc-xds-layers

Conversation

@YutaoMa
Copy link
Collaborator

@YutaoMa YutaoMa commented Mar 2, 2026

Motivation

Ref: #2444

xDS Resource Types and Route Matching

xds-client (PR #2478 ) handles the ADS protocol but knows nothing about gRPC. tonic-xds has its Tower service stack scaffolded but lacks the middle layer bridging xDS updates to routing decisions. This PR builds that foundation: validated resource types and a route matching engine that the upcoming resource manager will use to drive the LDS→RDS→CDS→EDS cascade and feed the existing Tower services.

This is the 1st PR of a series to complete tonic-xds. The next steps include:

  • xDS Resource cache
  • Endpoint management: EDS diffing into tower::discover::Change streams
  • Resource manager: cascade task managing LDS→RDS→CDS→EDS watches, implementing XdsRouter + XdsClusterDiscovery
  • Bootstrap config: JSON parsing from env vars → xds_client::ClientConfig
  • Builder wiring: wire full stack, E2E test
  • Advanced routing (gRFC A28+A63): Weighted cluster selection
  • Least request LB (gRFC A48)

Solution

Implements the xds_client::Resource trait for the four gRPC xDS resource types and adds a route compilation/matching engine, bridging xds-client watches to validated, efficient routing structures:

  • Resource types xds/resource/: ListenerResource (LDS), RouteConfigResource (RDS), ClusterResource (CDS), EndpointsResource (EDS) — each implements xds_client::Resource with two-phase decode (deserialize + validate).
  • Route matching xds/route/: CompiledRouteConfig pre-compiles a RouteConfigResource at RDS update time (regex compilation, domain indexing), allows for allocation-free per-request matching.
  • Refactors: RouteInput/RouteDecision moved to client/route (since it's used for Tower layer specifically, rather than the xDS subscription side of route logic this PR deals with).

@YutaoMa YutaoMa force-pushed the yutaoma/grpc-xds-layers branch from f7cb00d to 6040100 Compare March 3, 2026 00:39
@YutaoMa YutaoMa marked this pull request as ready for review March 3, 2026 00:57
@gu0keno0 gu0keno0 self-requested a review March 3, 2026 18:56
@YutaoMa YutaoMa force-pushed the yutaoma/grpc-xds-layers branch from c3fa3d9 to 4fad3bc Compare March 16, 2026 23:07
@YutaoMa YutaoMa merged commit 71af4b2 into hyperium:master Mar 17, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants