Struct axum_server::AddrIncomingConfig
source · pub struct AddrIncomingConfig { /* private fields */ }
Expand description
A configuration for AddrIncoming
.
Implementations§
source§impl AddrIncomingConfig
impl AddrIncomingConfig
sourcepub fn new() -> AddrIncomingConfig
pub fn new() -> AddrIncomingConfig
Creates a default AddrIncoming
config.
Examples found in repository?
examples/configure_addr_incoming.rs (line 14)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.tcp_keepalive_interval(Some(Duration::from_secs(1)))
.tcp_keepalive_retries(Some(1))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}
sourcepub fn build(&mut self) -> Self
pub fn build(&mut self) -> Self
Builds the config, creating an owned version of it.
Examples found in repository?
examples/configure_addr_incoming.rs (line 20)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.tcp_keepalive_interval(Some(Duration::from_secs(1)))
.tcp_keepalive_retries(Some(1))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}
sourcepub fn tcp_sleep_on_accept_errors(&mut self, val: bool) -> &mut Self
pub fn tcp_sleep_on_accept_errors(&mut self, val: bool) -> &mut Self
Set whether to sleep on accept errors, to avoid exhausting file descriptor limits.
Default is true
.
Examples found in repository?
examples/configure_addr_incoming.rs (line 16)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.tcp_keepalive_interval(Some(Duration::from_secs(1)))
.tcp_keepalive_retries(Some(1))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}
sourcepub fn tcp_keepalive(&mut self, val: Option<Duration>) -> &mut Self
pub fn tcp_keepalive(&mut self, val: Option<Duration>) -> &mut Self
Set how often to send TCP keepalive probes.
By default TCP keepalive probes is disabled.
Examples found in repository?
examples/configure_addr_incoming.rs (line 17)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.tcp_keepalive_interval(Some(Duration::from_secs(1)))
.tcp_keepalive_retries(Some(1))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}
sourcepub fn tcp_keepalive_interval(&mut self, val: Option<Duration>) -> &mut Self
pub fn tcp_keepalive_interval(&mut self, val: Option<Duration>) -> &mut Self
Set the duration between two successive TCP keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received.
Default is no interval.
Examples found in repository?
examples/configure_addr_incoming.rs (line 18)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.tcp_keepalive_interval(Some(Duration::from_secs(1)))
.tcp_keepalive_retries(Some(1))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}
sourcepub fn tcp_keepalive_retries(&mut self, val: Option<u32>) -> &mut Self
pub fn tcp_keepalive_retries(&mut self, val: Option<u32>) -> &mut Self
Set the number of retransmissions to be carried out before declaring that remote end is not available.
Default is no retry.
Examples found in repository?
examples/configure_addr_incoming.rs (line 19)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.tcp_keepalive_interval(Some(Duration::from_secs(1)))
.tcp_keepalive_retries(Some(1))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}
sourcepub fn tcp_nodelay(&mut self, val: bool) -> &mut Self
pub fn tcp_nodelay(&mut self, val: bool) -> &mut Self
Set the value of TCP_NODELAY
option for accepted connections.
Default is false
.
Examples found in repository?
examples/configure_addr_incoming.rs (line 15)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.tcp_keepalive_interval(Some(Duration::from_secs(1)))
.tcp_keepalive_retries(Some(1))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}
Trait Implementations§
source§impl Clone for AddrIncomingConfig
impl Clone for AddrIncomingConfig
source§fn clone(&self) -> AddrIncomingConfig
fn clone(&self) -> AddrIncomingConfig
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more