Skip to content

Commit

Permalink
allow nodelay to be set on prebound servers
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Oct 18, 2023
1 parent e9a40d9 commit 40830c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
14 changes: 2 additions & 12 deletions server-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ where
/// <https://en.wikipedia.org/wiki/Nagle%27s_algorithm> for more
/// information on this setting.
pub fn with_nodelay(mut self) -> Self {
if self.has_binding() {
eprintln!("constructing a config with both nodelay and a pre-bound listener will ignore the nodelay setting. this may be a panic in the future");
}

self.nodelay = true;
self
}
Expand Down Expand Up @@ -222,10 +218,8 @@ where
///
/// ## Note well
///
/// Many of the other options on this config will be ignored if
/// you provide a listener. In particular, `host`, `port`, and
/// `nodelay` will be ignored. All of the other options will be
/// used.
/// Many of the other options on this config will be ignored if you provide a listener. In
/// particular, `host` and `port` will be ignored. All of the other options will be used.
///
/// Additionally, cloning this config will not clone the listener.
pub fn with_prebound_server(mut self, server: impl Into<ServerType>) -> Self {
Expand All @@ -237,10 +231,6 @@ where
eprintln!("constructing a config with both a port and a pre-bound listener will ignore the port. this may be a panic in the future");
}

if self.nodelay {
eprintln!("constructing a config with nodelay and a pre-bound listener will ignore nodelay. this may be a panic in the future");
}

self.binding = RwLock::new(Some(server.into()));
self
}
Expand Down
1 change: 1 addition & 0 deletions tokio/examples/tokio_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub async fn main() {

trillium_tokio::config()
.with_prebound_server(server)
.with_nodelay()
.run_async(app())
.await;
}

0 comments on commit 40830c8

Please sign in to comment.