Skip to content

Commit b7a8882

Browse files
committed
add more docs
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
1 parent 5c215ad commit b7a8882

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

madsim-tonic/src/transport/channel.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ impl Endpoint {
7777
}
7878

7979
/// Sets the tower service default internal buffer size.
80+
///
81+
/// Note: this setting is currently ignored by the madsim transport implementation.
8082
pub fn buffer_size(self, sz: impl Into<Option<usize>>) -> Self {
8183
// ignore this setting
8284
let _ = sz.into();
@@ -105,6 +107,8 @@ impl Endpoint {
105107
}
106108

107109
/// Create a channel that connects lazily.
110+
///
111+
/// Note: madsim transport is not backed by a real HTTP/2 connection pool.
108112
pub fn connect_lazy(&self) -> Channel {
109113
Channel {
110114
ep: MultiEndpoint::new_one(self.clone()),
@@ -114,7 +118,7 @@ impl Endpoint {
114118

115119
/// Create a channel that connects lazily using a custom connector.
116120
///
117-
/// The connector is ignored in simulation mode.
121+
/// Note: the connector is currently ignored by the madsim transport implementation.
118122
pub fn connect_with_connector_lazy<C>(&self, _connector: C) -> Channel {
119123
self.connect_lazy()
120124
}
@@ -155,6 +159,8 @@ impl Endpoint {
155159
}
156160

157161
/// Configures TLS for the endpoint.
162+
///
163+
/// Note: TLS is currently ignored by the madsim transport implementation.
158164
#[cfg(any(
159165
feature = "tls-native-roots",
160166
feature = "tls-webpki-roots",
@@ -228,6 +234,8 @@ impl Endpoint {
228234
}
229235

230236
/// Sets the max size of received header frames.
237+
///
238+
/// Note: this setting is currently ignored by the madsim transport implementation.
231239
pub fn http2_max_header_list_size(self, size: u32) -> Self {
232240
// ignore this setting
233241
let _ = size;
@@ -236,7 +244,7 @@ impl Endpoint {
236244

237245
/// Sets the executor used to spawn async tasks.
238246
///
239-
/// The executor is ignored in simulation mode.
247+
/// Note: the executor is currently ignored by the madsim transport implementation.
240248
pub fn executor<E>(self, _executor: E) -> Self
241249
where
242250
E: Clone + Send + Sync + 'static,
@@ -246,7 +254,7 @@ impl Endpoint {
246254

247255
/// Sets the local address used when connecting.
248256
///
249-
/// The address is ignored in simulation mode.
257+
/// Note: the address is currently ignored by the madsim transport implementation.
250258
pub fn local_address(self, addr: Option<std::net::IpAddr>) -> Self {
251259
// ignore this setting
252260
let _ = addr;
@@ -258,15 +266,22 @@ impl Endpoint {
258266
&self.uri
259267
}
260268

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

277+
/// Returns the configured connect timeout.
266278
pub fn get_connect_timeout(&self) -> Option<Duration> {
267279
self.connect_timeout
268280
}
269281

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

madsim-tonic/src/transport/server.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ impl<L> Server<L> {
6868

6969
/// Create a router with the optional `S` typed service as the first service.
7070
///
71-
/// When `None`, this returns an empty router (requests will return Unimplemented).
71+
/// When `None`, this returns an empty router (requests will return
72+
/// [`Code::Unimplemented`]).
7273
pub fn add_optional_service<S>(&mut self, svc: Option<S>) -> Router<L>
7374
where
7475
S: Service<
@@ -182,13 +183,17 @@ impl<L> Server<L> {
182183
}
183184

184185
/// Sets the maximum time a connection may exist.
186+
///
187+
/// Note: this setting is currently ignored by the madsim transport implementation.
185188
#[must_use]
186189
pub fn max_connection_age(self, _max_connection_age: Duration) -> Self {
187190
// ignore this setting
188191
self
189192
}
190193

191194
/// Sets the max size of received header frames.
195+
///
196+
/// Note: this setting is currently ignored by the madsim transport implementation.
192197
#[must_use]
193198
pub fn http2_max_header_list_size(self, _max: impl Into<Option<u32>>) -> Self {
194199
// ignore this setting
@@ -224,6 +229,8 @@ impl<L> Server<L> {
224229
}
225230

226231
/// Intercept inbound headers and add a tracing span to each response future.
232+
///
233+
/// Note: this setting is currently ignored by the madsim transport implementation.
227234
#[must_use]
228235
pub fn trace_fn<FN>(self, _f: FN) -> Self
229236
where
@@ -273,6 +280,8 @@ impl<L> Router<L> {
273280
}
274281

275282
/// Add an optional service to this router.
283+
///
284+
/// When `None`, this leaves the router unchanged.
276285
pub fn add_optional_service<S>(self, svc: Option<S>) -> Self
277286
where
278287
S: Service<

0 commit comments

Comments
 (0)