Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## tonic [0.6.0] - 2026-02-05

### Changed
- tonic: Update `tonic` and `tonic-build` to v0.13.
- Align `tls` feature mapping with tonic v0.13 (`tls-native-roots`).

## etcd-client [0.7.0] - 2026-02-05

### Changed
- etcd-client: Update upstream `etcd-client` to v0.16.x (aligns tonic to v0.13.x).

## tonic [0.5.2] - 2025-12-03

### Changed
Expand Down
6 changes: 3 additions & 3 deletions madsim-etcd-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "madsim-etcd-client"
version = "0.6.0+0.14.0"
version = "0.7.0+0.16.0"
edition = "2021"
authors = ["Runji Wang <wangrunji0408@163.com>"]
description = "The etcd simulator on madsim."
Expand All @@ -13,7 +13,7 @@ license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[target.'cfg(not(madsim))'.dependencies]
etcd-client = "0.14"
etcd-client = "0.16"

[target.'cfg(madsim)'.dependencies]
http = "1"
Expand All @@ -24,7 +24,7 @@ serde_with = "3"
spin = "0.9"
thiserror = "1"
toml = "0.8"
tonic = { version = "0.12", default-features = false, features = ["transport"] }
tonic = { version = "0.13", default-features = false, features = ["transport"] }
tokio = { version = "1", features = ["sync"] }
tracing = "0.1"

Expand Down
4 changes: 2 additions & 2 deletions madsim-tonic-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "madsim-tonic-build"
version = "0.5.2+0.12.3"
version = "0.6.0+0.13"
edition = "2021"
authors = [
"Lucio Franco <luciofranco14@gmail.com>",
Expand All @@ -21,7 +21,7 @@ proc-macro2 = "1"
prost-build = { version = "0.13", optional = true }
quote = "1"
syn = "2"
tonic-build = "0.12.3"
tonic-build = "0.13"

[features]
default = ["transport", "prost"]
Expand Down
23 changes: 15 additions & 8 deletions madsim-tonic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "madsim-tonic"
version = "0.5.2+0.12.0"
version = "0.6.0+0.13"
edition = "2021"
authors = ["Runji Wang <wangrunji0408@163.com>"]
description = "The `tonic` simulator on madsim."
Expand All @@ -13,25 +13,32 @@ license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
# Tonic default features are always enabled via dependency defaults.
# We only expose non-default/extra tonic features here.
default = []
deflate = ["tonic/deflate"]
gzip = ["tonic/gzip"]
zstd = ["tonic/zstd"]
tls = ["tonic/tls"]

# TLS feature set in tonic 0.13.x.
tls = ["tls-native-roots"]
tls-aws-lc = ["tonic/tls-aws-lc"]
tls-native-roots = ["tonic/tls-native-roots"]
tls-ring = ["tonic/tls-ring"]
tls-webpki-roots = ["tonic/tls-webpki-roots"]

[target.'cfg(not(madsim))'.dependencies]
tonic = "0.12"
tonic = { version = "0.13" }

[target.'cfg(madsim)'.dependencies]
async-stream = "0.3"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
futures-util = "0.3"
madsim = { version = "0.2.20", path = "../madsim" }
tracing = "0.1"
tonic = { version = "0.12", default-features = false, features = [
"codegen",
"transport",
] }
tonic = { version = "0.13" }
tokio = "1"
tower = { version = "0.4.7" }
tower = { version = "0.5" }

[lints]
workspace = true
8 changes: 6 additions & 2 deletions madsim-tonic/src/sim.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use self::codec::Streaming;
pub use tonic::{
async_trait, body, metadata, service, Code, Extensions, IntoRequest, IntoStreamingRequest,
Request, Response, Status,
body, metadata, service, Code, Extensions, IntoRequest, IntoStreamingRequest, Request,
Response, Status,
};

#[macro_export]
Expand All @@ -16,6 +16,8 @@ pub mod codec;
pub(crate) mod tower;
pub mod transport;

pub use tonic::async_trait;

/// Append header to metadata.
trait AppendMetadata {
fn append_metadata(&mut self);
Expand Down Expand Up @@ -50,6 +52,8 @@ pub mod codegen {

pub use futures_util as futures;
pub use tonic::codegen::*;
// Generated code does `use tonic::codegen::*;` and then uses `#[async_trait]`.
pub use tonic::async_trait;

/// A type-erased message.
pub type BoxMessage = Box<dyn Any + Send + Sync>;
Expand Down
100 changes: 100 additions & 0 deletions madsim-tonic/src/transport/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ use std::{
time::Duration,
};
use tokio::sync::mpsc::{channel, Receiver, Sender};
#[cfg(any(
feature = "tls-native-roots",
feature = "tls-webpki-roots",
feature = "tls-ring",
feature = "tls-aws-lc"
))]
use tonic::transport::ClientTlsConfig;
use tonic::{
codegen::{http::HeaderValue, Bytes, StdError},
transport::Uri,
Expand Down Expand Up @@ -69,6 +76,15 @@ impl Endpoint {
}
}

/// Sets the tower service default internal buffer size.
///
/// Note: this setting is currently ignored by the madsim transport implementation.
pub fn buffer_size(self, sz: impl Into<Option<usize>>) -> Self {
// ignore this setting
let _ = sz.into();
self
}

/// Create a channel from this config.
pub async fn connect(&self) -> Result<Channel, Error> {
if let Some(dur) = self.connect_timeout {
Expand All @@ -90,6 +106,23 @@ impl Endpoint {
})
}

/// Create a channel that connects lazily.
///
/// Note: madsim transport is not backed by a real HTTP/2 connection pool.
pub fn connect_lazy(&self) -> Channel {
Channel {
ep: MultiEndpoint::new_one(self.clone()),
timeout: self.timeout,
}
}

/// Create a channel that connects lazily using a custom connector.
///
/// Note: the connector is currently ignored by the madsim transport implementation.
pub fn connect_with_connector_lazy<C>(&self, _connector: C) -> Channel {
self.connect_lazy()
}

/// Connect to a madsim Endpoint.
async fn connect_ep(&self) -> Result<madsim::net::Endpoint, Error> {
let host_port = (self.uri.authority())
Expand Down Expand Up @@ -125,6 +158,20 @@ impl Endpoint {
self
}

/// Configures TLS for the endpoint.
///
/// Note: TLS is currently ignored by the madsim transport implementation.
#[cfg(any(
feature = "tls-native-roots",
feature = "tls-webpki-roots",
feature = "tls-ring",
feature = "tls-aws-lc"
))]
pub fn tls_config(self, _tls_config: ClientTlsConfig) -> Result<Self, Error> {
// ignore this setting
Ok(self)
}

/// Set whether TCP keepalive messages are enabled on accepted connections.
pub fn tcp_keepalive(self, _tcp_keepalive: Option<Duration>) -> Self {
// ignore this setting
Expand Down Expand Up @@ -185,6 +232,59 @@ impl Endpoint {
// ignore this setting
self
}

/// Sets the max size of received header frames.
///
/// Note: this setting is currently ignored by the madsim transport implementation.
pub fn http2_max_header_list_size(self, size: u32) -> Self {
// ignore this setting
let _ = size;
self
}

/// Sets the executor used to spawn async tasks.
///
/// Note: the executor is currently ignored by the madsim transport implementation.
pub fn executor<E>(self, _executor: E) -> Self
where
E: Clone + Send + Sync + 'static,
{
self
}

/// Sets the local address used when connecting.
///
/// Note: the address is currently ignored by the madsim transport implementation.
pub fn local_address(self, addr: Option<std::net::IpAddr>) -> Self {
// ignore this setting
let _ = addr;
self
}

/// Get a reference to the configured URI.
pub fn uri(&self) -> &Uri {
&self.uri
}

/// Returns whether `TCP_NODELAY` is enabled.
///
/// Note: this always returns `true` for API compatibility.
pub fn get_tcp_nodelay(&self) -> bool {
// We don't store this option; tonic defaults to true.
true
}

/// Returns the configured connect timeout.
pub fn get_connect_timeout(&self) -> Option<Duration> {
self.connect_timeout
}

/// Returns the configured TCP keepalive setting.
///
/// Note: this always returns `None` for API compatibility.
pub fn get_tcp_keepalive(&self) -> Option<Duration> {
None
}
}

impl From<Uri> for Endpoint {
Expand Down
Loading
Loading