pub struct ServerConfig { /* private fields */ }Implementations§
Source§impl ServerConfig
impl ServerConfig
pub fn create(host: &str, port: u16, setup: FoxtiveSetup) -> ServerConfig
pub fn app(self, app: &str) -> Self
pub fn tracing(self, config: Tracing) -> Self
Sourcepub fn workers(self, workers: usize) -> Self
pub fn workers(self, workers: usize) -> Self
Set number of workers to start.
By default http server uses 2
Sourcepub fn backlog(self, backlog: i32) -> Self
pub fn backlog(self, backlog: i32) -> Self
Set the maximum number of pending connections.
This refers to the number of clients that can be waiting to be served. Exceeding this number results in the client getting an error when attempting to connect. It should only affect servers under significant load.
Generally set in the 64-2048 range. Default value is 2048.
This method should be called before bind() method call.
Sourcepub fn keep_alive(self, keep_alive: Seconds) -> Self
pub fn keep_alive(self, keep_alive: Seconds) -> Self
Set server keep-alive setting.
By default keep alive is set to a 5 seconds.
Sourcepub fn client_timeout(self, timeout: u16) -> Self
pub fn client_timeout(self, timeout: u16) -> Self
Set request read timeout in seconds.
Defines a timeout for reading client request headers. If a client does not transmit the entire set headers within this time, the request is terminated with the 408 (Request Time-out) error.
To disable timeout set value to 0.
By default client timeout is set to 3 seconds.
Sourcepub fn client_disconnect(self, timeout: u16) -> Self
pub fn client_disconnect(self, timeout: u16) -> Self
Set server connection disconnect timeout in seconds.
Defines a timeout for shutdown connection. If a shutdown procedure does not complete within this time, the request is dropped.
To disable timeout set value to 0.
By default client timeout is set to 5 seconds.
Sourcepub fn max_conn(self, max: usize) -> Self
pub fn max_conn(self, max: usize) -> Self
Sets the maximum per-worker number of concurrent connections.
All socket listeners will stop accepting connections when this limit is reached for each worker.
By default max connections is set to a 25k.
Sourcepub fn max_conn_rate(self, max: usize) -> Self
pub fn max_conn_rate(self, max: usize) -> Self
Sets the maximum per-worker concurrent connection establish process.
All listeners will stop accepting connections when this limit is reached. It can be used to limit the global SSL CPU usage.
By default max connections is set to a 256.
pub fn allowed_origins(self, allowed_origins: Vec<String>) -> Self
pub fn allowed_methods(self, allowed_methods: Vec<Method>) -> Self
pub fn boot_thread( self, boot_thread: Arc<dyn Fn() -> Vec<Route> + Send + Sync>, ) -> Self
pub fn has_started_bootstrap(self, has_started_bootstrap: bool) -> Self
pub fn json_config(self, json_config: JsonConfig) -> Self
Sourcepub fn on_shutdown<F>(self, func: F) -> Self
pub fn on_shutdown<F>(self, func: F) -> Self
Sets a custom shutdown handler to be called when the application is shutting down.
This method allows you to provide a future that will be awaited during shutdown. It is typically used to perform cleanup tasks like closing database connections, flushing logs, or other async teardown operations.
Note: If a custom shutdown_signal is also provided using [shutdown_signal],
that will take precedence over this handler, and this on_shutdown handler will
not be executed.
Sourcepub fn shutdown_signal<F>(self, func: F) -> Self
pub fn shutdown_signal<F>(self, func: F) -> Self
Sets a custom shutdown signal handler that determines when the application should begin shutting down.
This method allows you to provide a future that, when resolved, triggers the application shutdown.
It is typically used to listen for signals like Ctrl+C or system termination requests (SIGTERM).
If this shutdown signal is provided, it will override any handler set using [on_shutdown].