Skip to content

Commit cb534a7

Browse files
authored
feat: Add tcp setting getters to endpoint (#1983)
Add getters for tcp settings to Endpoints. The purpose for this is that `connect_with_connector` doesn't set TCP settings on the socket, because it's using a provided connector. In the cases where a library is creating a custom TCP connection, we want to be able to respect user tcp settings, in particular connection timeout. Adding these getters allows this.
1 parent 5c9fa88 commit cb534a7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tonic/src/transport/channel/endpoint.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,25 @@ impl Endpoint {
415415
pub fn uri(&self) -> &Uri {
416416
&self.uri
417417
}
418+
419+
/// Get the value of `TCP_NODELAY` option for accepted connections.
420+
pub fn get_tcp_nodelay(&self) -> bool {
421+
self.tcp_nodelay
422+
}
423+
424+
/// Get the connect timeout.
425+
pub fn get_connect_timeout(&self) -> Option<Duration> {
426+
self.connect_timeout
427+
}
428+
429+
/// Get whether TCP keepalive messages are enabled on accepted connections.
430+
///
431+
/// If `None` is specified, keepalive is disabled, otherwise the duration
432+
/// specified will be the time to remain idle before sending TCP keepalive
433+
/// probes.
434+
pub fn get_tcp_keepalive(&self) -> Option<Duration> {
435+
self.tcp_keepalive
436+
}
418437
}
419438

420439
impl From<Uri> for Endpoint {

0 commit comments

Comments
 (0)