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
👎Deprecated since 4.3.0: affinity is enabled by default, use affinity() to change it
pub fn enable_affinity(self) -> Self
affinity is enabled by default, use affinity() to change it
Does nothing, affinity is enabled by default.
Sourcepub fn affinity(self, affinity: Affinity) -> Self
pub fn affinity(self, affinity: Affinity) -> Self
Sets the CPU affinity of worker threads.
Workers are spread over physical cores first, see Affinity.
By default, Affinity::Soft is used on Windows and
Affinity::Core on other platforms.
Sourcepub fn load_balancing(self, balancing: LoadBalancing) -> Self
pub fn load_balancing(self, balancing: LoadBalancing) -> Self
Sets how items are distributed between workers.
By default, LoadBalancing::IncomingCpu sends new items to idle
workers, which helps when connections are long-lived or their load is
uneven, and prefers the worker on the CPU that receives a connection’s
network packets. LoadBalancing::RoundRobin sends them to the
workers in turn.