Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grpc-xds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ allowed_external_types = []
protobuf = "4.35.1-release"
protobuf-well-known-types = "4.35.1-release"
bytes = "1.11.0"
xds-client = { version = "0.1.0-alpha.2", path = "../xds-client", default-features = false }
xds-client = { version = "0.1.0-alpha.3", path = "../xds-client", default-features = false }
regex = "1"

[build-dependencies]
Expand Down
9 changes: 5 additions & 4 deletions tonic-xds/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tonic-xds"
version = "0.1.0-alpha.2"
version = "0.1.0-alpha.3"
edition = "2024"
rust-version.workspace = true
homepage = "https://github.com/hyperium/tonic"
Expand Down Expand Up @@ -33,7 +33,7 @@ url = "2.5.8"
futures-core = "0.3.31"
futures-util = "0.3"
bytes = "1"
xds-client = { version = "0.1.0-alpha.2", path = "../xds-client" }
xds-client = { version = "0.1.0-alpha.3", path = "../xds-client" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
envoy-types = "0.7"
Expand All @@ -56,13 +56,13 @@ rustls = { version = "0.23", default-features = false, features = ["std", "tls12
rustls-pemfile = { version = "2", optional = true }
x509-parser = { version = "0.17", optional = true }
opentelemetry = { version = "0.32", optional = true, default-features = false, features = ["metrics"] }
xds-client-opentelemetry = { version = "0.1.0-alpha.2", path = "../xds-client-opentelemetry", optional = true }
xds-client-opentelemetry = { version = "0.1.0-alpha.3", path = "../xds-client-opentelemetry", optional = true }

[lints]
workspace = true

[dev-dependencies]
xds-client = { version = "0.1.0-alpha.2", path = "../xds-client", features = ["test-util"] }
xds-client = { version = "0.1.0-alpha.3", path = "../xds-client", features = ["test-util"] }
xds-test-util = { path = "../xds-test-util" }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "test-util"] }
tonic = { version = "0.14", features = [ "server", "channel", "tls-ring" ] }
Expand Down Expand Up @@ -123,5 +123,6 @@ allowed_external_types = [
"tower::util::boxed_clone_sync::BoxCloneSyncService",
"url::parser::ParseError",
"serde_core::de::Deserialize",
"serde_core::ser::Serialize",
"serde_json::error::Error",
]
2 changes: 1 addition & 1 deletion tonic-xds/examples/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
//! cargo run -p tonic-xds --example xds_server
//!
//! # Terminal 3: xDS client
//! GRPC_XDS_BOOTSTRAP_CONFIG='{"xds_servers":[{"server_uri":"http://localhost:18000"}],"node":{"id":"test"}}' \
//! GRPC_XDS_BOOTSTRAP_CONFIG='{"xds_servers":[{"server_uri":"http://localhost:18000","channel_creds":[{"type":"insecure"}]}],"node":{"id":"test"}}' \
//! cargo run -p tonic-xds --example channel --features testutil
//! ```
//!
Expand Down
2 changes: 1 addition & 1 deletion tonic-xds/examples/run_xds_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ XDS_PID=$!
sleep 2

# 3. Run xDS-aware client
GRPC_XDS_BOOTSTRAP_CONFIG='{"xds_servers":[{"server_uri":"http://localhost:18000"}],"node":{"id":"test"}}' \
GRPC_XDS_BOOTSTRAP_CONFIG='{"xds_servers":[{"server_uri":"http://localhost:18000","channel_creds":[{"type":"insecure"}]}],"node":{"id":"test"}}' \
cargo run -p tonic-xds --example channel --features testutil 2>&1 | prefix "client"
2 changes: 1 addition & 1 deletion tonic-xds/src/client/xds_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod test {
/// target resolves the listener `listener_name`.
fn build_channel(cp_addr: SocketAddr, listener_name: &str) -> XdsChannelGrpc {
let bootstrap_json = format!(
r#"{{"xds_servers":[{{"server_uri":"http://{cp_addr}"}}],"node":{{"id":"test"}}}}"#
r#"{{"xds_servers":[{{"server_uri":"http://{cp_addr}","channel_creds":[{{"type":"insecure"}}]}}],"node":{{"id":"test"}}}}"#
);
let bootstrap = BootstrapConfig::from_json(&bootstrap_json).expect("parse bootstrap");
let target = XdsUri::parse(&format!("xds:///{listener_name}")).expect("parse target");
Expand Down
47 changes: 40 additions & 7 deletions tonic-xds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
//!
//! 1. **Provide a bootstrap configuration** that tells the client where
//! the xDS management server lives and what node identity to present.
//! The format matches [gRFC A27] — a JSON object with `xds_servers`
//! and an optional `node`.
//! The format matches [gRFC A27] — a JSON object with `xds_servers`,
//! each entry carrying a `server_uri` and the `channel_creds` types the
//! client may offer, plus an optional `node`.
//!
//! 2. **Build the channel** with [`XdsChannelBuilder`], pointing it at
//! an `xds:///` target URI.
Expand All @@ -54,7 +55,8 @@
//!
//! | Method | How |
//! |--------|-----|
//! | Programmatic | [`BootstrapConfig::from_json`] then [`XdsChannelConfig::with_bootstrap`] |
//! | Programmatic (builder) | [`BootstrapConfig::builder`] then [`XdsChannelConfig::with_bootstrap`] |
//! | Programmatic (JSON) | [`BootstrapConfig::from_json`] then [`XdsChannelConfig::with_bootstrap`] |
//! | Environment (explicit) | [`XdsChannelConfig::with_bootstrap_from_env`] |
//! | Environment (implicit) | Omit bootstrap; the builder loads from env vars automatically |
//!
Expand All @@ -66,7 +68,10 @@
//!
//! ```json
//! {
//! "xds_servers": [{"server_uri": "xds.example.com:443"}],
//! "xds_servers": [{
//! "server_uri": "xds.example.com:443",
//! "channel_creds": [{"type": "tls"}]
//! }],
//! "node": {"id": "my-node"}
//! }
//! ```
Expand All @@ -93,7 +98,10 @@
//! use tonic_xds::{BootstrapConfig, XdsChannelBuilder, XdsChannelConfig, XdsUri};
//!
//! let bootstrap = BootstrapConfig::from_json(r#"{
//! "xds_servers": [{"server_uri": "xds.example.com:443"}],
//! "xds_servers": [{
//! "server_uri": "xds.example.com:443",
//! "channel_creds": [{"type": "tls"}]
//! }],
//! "node": {"id": "my-node", "cluster": "my-cluster"}
//! }"#).unwrap();
//!
Expand All @@ -105,6 +113,26 @@
//! // let client = MyServiceClient::new(channel);
//! ```
//!
//! ### Using the builder
//!
//! ```rust,no_run
//! use tonic_xds::{BootstrapConfig, ChannelCredentialType, XdsChannelBuilder, XdsChannelConfig, XdsUri};
//!
//! let bootstrap = BootstrapConfig::builder("xds.example.com:443")
//! .channel_creds([ChannelCredentialType::Tls])
//! .node_id("my-node")
//! .node_cluster("my-cluster")
//! .build()
//! .unwrap();
//!
//! let target = XdsUri::parse("xds:///myservice:50051").unwrap();
//! let channel = XdsChannelBuilder::new(
//! XdsChannelConfig::new(target).with_bootstrap(bootstrap),
//! ).build_grpc_channel().unwrap();
//!
//! // let client = MyServiceClient::new(channel);
//! ```
//!
//! ## TLS Security (gRFC A29)
//!
//! Upstream data-plane TLS is enabled when:
Expand All @@ -121,7 +149,10 @@
//!
//! ```json
//! {
//! "xds_servers": [{"server_uri": "xds.example.com:443"}],
//! "xds_servers": [{
//! "server_uri": "xds.example.com:443",
//! "channel_creds": [{"type": "tls"}]
//! }],
//! "certificate_providers": {
//! "root_ca": { "plugin_name": "file_watcher", "config": {
//! "ca_certificate_file": "/etc/certs/ca.pem"
Expand Down Expand Up @@ -182,7 +213,9 @@ pub use client::retry::{
pub use client::route::PreRouteInterceptor;
pub use common::async_util::BoxFuture;
pub use shared_http_body::SharedBody;
pub use xds::bootstrap::{BootstrapConfig, BootstrapError};
pub use xds::bootstrap::{
BootstrapConfig, BootstrapConfigBuilder, BootstrapError, ChannelCredentialType,
};
pub use xds::resource::route_config::{RouteConfigMetadata, TypedMetadata};
pub use xds::uri::{XdsUri, XdsUriError};
pub use xds_client::TonicCallCredentials;
Expand Down
Loading
Loading