Skip to content

Commit 0f20b7e

Browse files
committed
tonic: fix consistency issue with timeout func in transport/server builder
transport/server/mod.rs exposes a Builder for the Server, and most of the Builder functions return Self (a change made for issue #115), but timeout returns mut& Self. This change makes timeout consistent with the rest of the Builder api by returning Self. Fixes: #900 Refs: #115
1 parent a337f13 commit 0f20b7e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • tonic/src/transport/server

tonic/src/transport/server/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,14 @@ impl<L> Server<L> {
186186
/// # use tonic::transport::Server;
187187
/// # use tower_service::Service;
188188
/// # use std::time::Duration;
189-
/// # let mut builder = Server::builder();
189+
/// # let builder = Server::builder();
190190
/// builder.timeout(Duration::from_secs(30));
191191
/// ```
192-
pub fn timeout(&mut self, timeout: Duration) -> &mut Self {
193-
self.timeout = Some(timeout);
194-
self
192+
pub fn timeout(self, timeout: Duration) -> Self {
193+
Server {
194+
timeout: Some(timeout),
195+
..self
196+
}
195197
}
196198

197199
/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2

0 commit comments

Comments
 (0)