Struct ntex::server::ServerBuilder [−][src]
pub struct ServerBuilder { /* fields omitted */ }
Expand description
Server builder
Implementations
pub fn new() -> ServerBuilderⓘNotable traits for ServerBuilderimpl Future for ServerBuilder type Output = ();
pub fn new() -> ServerBuilderⓘNotable traits for ServerBuilderimpl Future for ServerBuilder type Output = ();
impl Future for ServerBuilder type Output = ();
Create new Server builder instance
Set number of workers to start.
By default server uses number of available logical cpu as workers count.
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.
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 per worker.
Stop ntex runtime when server get dropped.
By default “stop runtime” is disabled.
Disable signal handling.
By default signal handling is enabled.
Timeout for graceful workers shutdown.
After receiving a stop signal, workers have this much time to finish serving requests. Workers still alive after the timeout are force dropped.
By default shutdown timeout sets to 30 seconds.
pub fn status_handler<F>(self, handler: F) -> Self where
F: FnMut(ServerStatus) + Send + 'static,
pub fn status_handler<F>(self, handler: F) -> Self where
F: FnMut(ServerStatus) + Send + 'static,
Set server status handler.
Server calls this handler on every inner status update.
pub fn configure<F>(self, f: F) -> Result<ServerBuilder> where
F: Fn(&mut ServiceConfig) -> Result<()>,
pub fn configure<F>(self, f: F) -> Result<ServerBuilder> where
F: Fn(&mut ServiceConfig) -> Result<()>,
Execute external configuration as part of the server building process.
This function is useful for moving parts of configuration to a different module or even library.
pub fn on_worker_start<F, R, E>(self, f: F) -> Self where
F: Fn(ServiceRuntime) -> R + Send + Clone + 'static,
R: Future<Output = Result<(), E>> + 'static,
E: Display + 'static,
pub fn on_worker_start<F, R, E>(self, f: F) -> Self where
F: Fn(ServiceRuntime) -> R + Send + Clone + 'static,
R: Future<Output = Result<(), E>> + 'static,
E: Display + 'static,
Register async service configuration function.
This function get called during worker runtime configuration stage. It get executed in the worker thread.
Add new service to the server.
Add new unix domain service to the server.
pub fn listen_uds<F, N: AsRef<str>, R>(
self,
name: N,
lst: UnixListener,
factory: F
) -> Result<Self> where
F: Fn(Config) -> R + Send + Clone + 'static,
R: ServiceFactory<Io>,
pub fn listen_uds<F, N: AsRef<str>, R>(
self,
name: N,
lst: UnixListener,
factory: F
) -> Result<Self> where
F: Fn(Config) -> R + Send + Clone + 'static,
R: ServiceFactory<Io>,
Add new unix domain service to the server. Useful when running as a systemd service and a socket FD can be acquired using the systemd crate.
Add new service to the server.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for ServerBuilder
impl Send for ServerBuilder
impl !Sync for ServerBuilder
impl Unpin for ServerBuilder
impl !UnwindSafe for ServerBuilder
Blanket Implementations
Mutably borrows from an owned value. Read more
Map this future’s output to a different type, returning a new future of the resulting type. Read more
Map this future’s output to a different type, returning a new future of the resulting type. Read more
Chain on a computation for when a future finished, passing the result of
the future to the provided closure f
. Read more
fn left_future<B>(self) -> Either<Self, B> where
B: Future<Output = Self::Output>,
fn left_future<B>(self) -> Either<Self, B> where
B: Future<Output = Self::Output>,
Wrap this future in an Either
future, making it the left-hand variant
of that Either
. Read more
fn right_future<A>(self) -> Either<A, Self> where
A: Future<Output = Self::Output>,
fn right_future<A>(self) -> Either<A, Self> where
A: Future<Output = Self::Output>,
Wrap this future in an Either
future, making it the right-hand variant
of that Either
. Read more
fn into_stream(self) -> IntoStream<Self>
fn into_stream(self) -> IntoStream<Self>
Convert this future into a single element stream. Read more
Flatten the execution of this future when the output of this future is itself another future. Read more
fn flatten_stream(self) -> FlattenStream<Self> where
Self::Output: Stream,
fn flatten_stream(self) -> FlattenStream<Self> where
Self::Output: Stream,
Flatten the execution of this future when the successful result of this future is a stream. Read more
fn fuse(self) -> Fuse<Self>
fn fuse(self) -> Fuse<Self>
Fuse a future such that poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read more
Do something with the output of a future before passing it on. Read more
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
Catches unwinding panics while polling the future. Read more
Create a cloneable handle to this future where all handles will resolve to the same result. Read more
Wrap the future in a Box, pinning it. Read more
Wrap the future in a Box, pinning it. Read more
fn unit_error(self) -> UnitError<Self>
fn unit_error(self) -> UnitError<Self>
Turns a Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>. Read more
fn never_error(self) -> NeverError<Self>
fn never_error(self) -> NeverError<Self>
Turns a Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>. Read more
fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output> where
Self: Unpin,
fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output> where
Self: Unpin,
A convenience for calling Future::poll
on Unpin
future types.
fn now_or_never(self) -> Option<Self::Output>
fn now_or_never(self) -> Option<Self::Output>
Evaluates and consumes the future, returning the resulting output if
the future is ready after the first call to Future::poll
. Read more
into_future
)The output that the future will produce on completion.
type Future = F
type Future = F
into_future
)Which kind of future are we turning this into?
into_future
)Creates a future from a value.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more