From 8ae57aa52a54cf70ae8b2361b791b36a0e313ee4 Mon Sep 17 00:00:00 2001 From: YutaoMa Date: Thu, 4 Dec 2025 16:41:33 -0800 Subject: [PATCH 1/3] xds: init crate Initialize the crate scaffolding for xds-client. Refs: #2444 --- Cargo.toml | 1 + xds-client/Cargo.toml | 21 +++++++++++++++++++++ xds-client/src/client/mod.rs | 1 + xds-client/src/error.rs | 1 + xds-client/src/lib.rs | 13 +++++++++++++ xds-client/src/resource/mod.rs | 4 ++++ xds-client/src/resource/prost.rs | 1 + xds-client/src/runtime/mod.rs | 4 ++++ xds-client/src/runtime/tokio.rs | 1 + xds-client/src/transport/mod.rs | 4 ++++ xds-client/src/transport/tonic.rs | 1 + 11 files changed, 52 insertions(+) create mode 100644 xds-client/Cargo.toml create mode 100644 xds-client/src/client/mod.rs create mode 100644 xds-client/src/error.rs create mode 100644 xds-client/src/lib.rs create mode 100644 xds-client/src/resource/mod.rs create mode 100644 xds-client/src/resource/prost.rs create mode 100644 xds-client/src/runtime/mod.rs create mode 100644 xds-client/src/runtime/tokio.rs create mode 100644 xds-client/src/transport/mod.rs create mode 100644 xds-client/src/transport/tonic.rs diff --git a/Cargo.toml b/Cargo.toml index ca4f737f2..b89fe5ab3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "examples", "codegen", "grpc", + "xds-client", "interop", # Tests "tests/disable_comments", "tests/wellknown", diff --git a/xds-client/Cargo.toml b/xds-client/Cargo.toml new file mode 100644 index 000000000..b9c6a035a --- /dev/null +++ b/xds-client/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "xds-client" +version = "0.1.0-alpha.1" +edition = "2021" +license = "MIT" +rust-version = { workspace = true } + +[lints] +workspace = true + +[dependencies] +tonic = { version = "0.14", path = "../tonic", optional = true } +tokio = { version = "1", optional = true } +prost = { version = "0.14", optional = true } +prost-types = { version = "0.14", optional = true } + +[features] +default = ["transport-tonic"] +transport-tonic = ["dep:tonic", "rt-tokio", "codegen-prost"] +rt-tokio = ["dep:tokio"] +codegen-prost = ["dep:prost", "dep:prost-types"] \ No newline at end of file diff --git a/xds-client/src/client/mod.rs b/xds-client/src/client/mod.rs new file mode 100644 index 000000000..a5e53b7e0 --- /dev/null +++ b/xds-client/src/client/mod.rs @@ -0,0 +1 @@ +//! Client interface through which the user can watch and receive updates for xDS resources. diff --git a/xds-client/src/error.rs b/xds-client/src/error.rs new file mode 100644 index 000000000..3801c7b06 --- /dev/null +++ b/xds-client/src/error.rs @@ -0,0 +1 @@ +//! Error types for the xDS client. diff --git a/xds-client/src/lib.rs b/xds-client/src/lib.rs new file mode 100644 index 000000000..e2420a0b1 --- /dev/null +++ b/xds-client/src/lib.rs @@ -0,0 +1,13 @@ +//! A Rust implementation of [xDS](https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol) client. +//! +//! # Feature Flags +//! +//! - `transport-tonic`: Enables the use of the `tonic` transport. This enables `rt-tokio` and `codegen-prost` features. Enabled by default. +//! - `rt-tokio`: Enables the use of the `tokio` runtime. Enabled by default. +//! - `codegen-prost`: Enables the use of the `prost` codec generated resources. Enabled by default. + +pub mod client; +pub mod error; +pub mod resource; +pub mod runtime; +pub mod transport; diff --git a/xds-client/src/resource/mod.rs b/xds-client/src/resource/mod.rs new file mode 100644 index 000000000..0f83946f2 --- /dev/null +++ b/xds-client/src/resource/mod.rs @@ -0,0 +1,4 @@ +//! Provides abstraction for xDS resources. + +#[cfg(feature = "codegen-prost")] +pub mod prost; diff --git a/xds-client/src/resource/prost.rs b/xds-client/src/resource/prost.rs new file mode 100644 index 000000000..879d33a6f --- /dev/null +++ b/xds-client/src/resource/prost.rs @@ -0,0 +1 @@ +//! `prost` codec-specific resources. diff --git a/xds-client/src/runtime/mod.rs b/xds-client/src/runtime/mod.rs new file mode 100644 index 000000000..0173a8c8c --- /dev/null +++ b/xds-client/src/runtime/mod.rs @@ -0,0 +1,4 @@ +//! Provides abstraction for async runtimes. + +#[cfg(feature = "rt-tokio")] +pub mod tokio; diff --git a/xds-client/src/runtime/tokio.rs b/xds-client/src/runtime/tokio.rs new file mode 100644 index 000000000..ed894730b --- /dev/null +++ b/xds-client/src/runtime/tokio.rs @@ -0,0 +1 @@ +//! `tokio` based runtime implementation. diff --git a/xds-client/src/transport/mod.rs b/xds-client/src/transport/mod.rs new file mode 100644 index 000000000..a162b11e9 --- /dev/null +++ b/xds-client/src/transport/mod.rs @@ -0,0 +1,4 @@ +//! Provides abstraction for transport layers. + +#[cfg(feature = "transport-tonic")] +pub mod tonic; diff --git a/xds-client/src/transport/tonic.rs b/xds-client/src/transport/tonic.rs new file mode 100644 index 000000000..068c36f37 --- /dev/null +++ b/xds-client/src/transport/tonic.rs @@ -0,0 +1 @@ +//! `tonic` based transport implementation. From c14c87a973d200fa2720e76148887363d9196463 Mon Sep 17 00:00:00 2001 From: YutaoMa Date: Fri, 5 Dec 2025 13:08:16 -0800 Subject: [PATCH 2/3] chore(xds): add crate description --- xds-client/Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xds-client/Cargo.toml b/xds-client/Cargo.toml index b9c6a035a..2ba3f2477 100644 --- a/xds-client/Cargo.toml +++ b/xds-client/Cargo.toml @@ -1,7 +1,10 @@ [package] name = "xds-client" +description = "An xDS client implementation in Rust" version = "0.1.0-alpha.1" edition = "2021" +homepage = "https://github.com/hyperium/tonic" +repository = "https://github.com/hyperium/tonic" license = "MIT" rust-version = { workspace = true } @@ -18,4 +21,4 @@ prost-types = { version = "0.14", optional = true } default = ["transport-tonic"] transport-tonic = ["dep:tonic", "rt-tokio", "codegen-prost"] rt-tokio = ["dep:tokio"] -codegen-prost = ["dep:prost", "dep:prost-types"] \ No newline at end of file +codegen-prost = ["dep:prost", "dep:prost-types"] From 1d53bec930dc160648154da4b452fdcf970314e2 Mon Sep 17 00:00:00 2001 From: YutaoMa Date: Fri, 5 Dec 2025 13:21:57 -0800 Subject: [PATCH 3/3] chore(xds): remove unused dependencies --- xds-client/Cargo.toml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/xds-client/Cargo.toml b/xds-client/Cargo.toml index 2ba3f2477..b1e247617 100644 --- a/xds-client/Cargo.toml +++ b/xds-client/Cargo.toml @@ -12,13 +12,9 @@ rust-version = { workspace = true } workspace = true [dependencies] -tonic = { version = "0.14", path = "../tonic", optional = true } -tokio = { version = "1", optional = true } -prost = { version = "0.14", optional = true } -prost-types = { version = "0.14", optional = true } [features] default = ["transport-tonic"] -transport-tonic = ["dep:tonic", "rt-tokio", "codegen-prost"] -rt-tokio = ["dep:tokio"] -codegen-prost = ["dep:prost", "dep:prost-types"] +transport-tonic = ["rt-tokio", "codegen-prost"] +rt-tokio = [] +codegen-prost = []