pub struct WorkerPool { /* private fields */ }Expand description
Builder for a pool of server workers.
Implementations§
Source§impl WorkerPool
impl WorkerPool
Sourcepub fn name<T: AsRef<str>>(self, name: T) -> Self
pub fn name<T: AsRef<str>>(self, name: T) -> Self
Sets the worker thread name prefix.
The configured name is used for worker thread names.
Sourcepub fn workers(self, num: usize) -> Self
pub fn workers(self, num: usize) -> Self
Sets the number of worker threads to start.
By default, the server uses the number of available logical CPUs.
Sourcepub fn stop_runtime(self) -> Self
pub fn stop_runtime(self) -> Self
Stops the current ntex runtime after the server has stopped.
By default, “stop runtime” is disabled.
Sourcepub fn stop_on_panic(self) -> Self
pub fn stop_on_panic(self) -> Self
Stops the server when one of the workers fails.
A worker fails when it panics or its service cannot be created. The
stop is graceful only if graceful_shutdown
is enabled. Without this option, a failed worker is restarted.
By default, “stop on panic” is disabled.
Sourcepub fn disable_signals(self) -> Self
pub fn disable_signals(self) -> Self
Disables signal handling.
By default, the server stops on SIGINT, SIGTERM, and SIGQUIT.
Sourcepub fn graceful_shutdown(self) -> Self
pub fn graceful_shutdown(self) -> Self
Enables graceful shutdown on SIGQUIT, fatal signals, and panics.
When enabled, SIGQUIT, SIGSEGV, SIGABRT, application panics, and worker failures with “stop on panic” stop the server gracefully. SIGTERM always stops gracefully and SIGINT always stops immediately.
By default, these events stop the server immediately.
Sourcepub fn graceful_shutdown_timeout<T: Into<Millis>>(self, timeout: T) -> Self
pub fn graceful_shutdown_timeout<T: Into<Millis>>(self, timeout: T) -> Self
Timeout for graceful worker shutdown.
After receiving a stop signal, workers have this much time to finish serving requests. Workers that are still alive after the timeout are forcefully dropped.
This bounds the worker as a whole, not an individual connection. Each
connection is bound separately by IoConfig::set_shutdown_timeout, so
this value should leave room for the connections a worker is still
draining to shut down themselves.
By default, the timeout is set to 30 seconds.
Sourcepub fn enable_affinity(self) -> Self
pub fn enable_affinity(self) -> Self
Enables CPU affinity for worker threads.
By default, affinity is disabled.
Trait Implementations§
Source§impl Clone for WorkerPool
impl Clone for WorkerPool
Source§fn clone(&self) -> WorkerPool
fn clone(&self) -> WorkerPool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more