Struct actix_server::ServerBuilder
source · pub struct ServerBuilder { /* private fields */ }
Expand description
Server builder
Implementations§
source§impl ServerBuilder
impl ServerBuilder
sourcepub fn new() -> ServerBuilder
pub fn new() -> ServerBuilder
Create new Server builder instance
sourcepub fn workers(self, num: usize) -> Self
pub fn workers(self, num: usize) -> Self
Set number of workers to start.
By default server uses number of available logical cpu as workers count.
sourcepub fn maxconn(self, num: usize) -> Self
pub fn maxconn(self, num: 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 per worker.
sourcepub fn system_exit(self) -> Self
pub fn system_exit(self) -> Self
Stop actix system.
SystemExit
message stops currently running system.
sourcepub fn disable_signals(self) -> Self
pub fn disable_signals(self) -> Self
Disable signal handling
sourcepub fn shutdown_timeout(self, sec: u16) -> Self
pub fn shutdown_timeout(self, sec: u16) -> Self
Timeout for graceful workers shutdown in seconds.
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.
sourcepub 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.
sourcepub fn bind<F, U, N: AsRef<str>>(
self,
name: N,
addr: U,
factory: F
) -> Result<Self>where
F: StreamServiceFactory,
U: ToSocketAddrs,
pub fn bind<F, U, N: AsRef<str>>(
self,
name: N,
addr: U,
factory: F
) -> Result<Self>where
F: StreamServiceFactory,
U: ToSocketAddrs,
Add new service to the server.
sourcepub fn listen<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Selfwhere
F: StreamServiceFactory,
pub fn listen<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Selfwhere
F: StreamServiceFactory,
Add new service to the server.
sourcepub fn listen2<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Selfwhere
F: ServiceFactory,
pub fn listen2<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Selfwhere
F: ServiceFactory,
Add new service to the server.
sourcepub fn run(self)
pub fn run(self)
Spawn new thread and start listening for incoming connections.
This method spawns new thread and starts new actix system. Other than
that it is similar to start()
method. This method blocks.
This methods panics if no socket addresses get bound.
use actix_web::*;
fn main() {
Server::new().
.service(
HttpServer::new(|| App::new().resource("/", |r| r.h(|_| HttpResponse::Ok())))
.bind("127.0.0.1:0")
.expect("Can not bind to 127.0.0.1:0"))
.run();
}
Trait Implementations§
source§impl Default for ServerBuilder
impl Default for ServerBuilder
source§impl Future for ServerBuilder
impl Future for ServerBuilder
§type Error = ()
type Error = ()
source§fn poll(&mut self) -> Poll<Self::Item, Self::Error>
fn poll(&mut self) -> Poll<Self::Item, Self::Error>
source§fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
source§fn map<F, U>(self, f: F) -> Map<Self, F>where
F: FnOnce(Self::Item) -> U,
Self: Sized,
fn map<F, U>(self, f: F) -> Map<Self, F>where
F: FnOnce(Self::Item) -> U,
Self: Sized,
source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>where
F: FnOnce(Self::Error) -> E,
Self: Sized,
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>where
F: FnOnce(Self::Error) -> E,
Self: Sized,
source§fn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
fn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
From
for
this future’s Error
, returning a new future. Read moresource§fn then<F, B>(self, f: F) -> Then<Self, B, F>where
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
B: IntoFuture,
Self: Sized,
fn then<F, B>(self, f: F) -> Then<Self, B, F>where
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
B: IntoFuture,
Self: Sized,
f
. Read moresource§fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>where
F: FnOnce(Self::Item) -> B,
B: IntoFuture<Error = Self::Error>,
Self: Sized,
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>where
F: FnOnce(Self::Item) -> B,
B: IntoFuture<Error = Self::Error>,
Self: Sized,
source§fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>where
F: FnOnce(Self::Error) -> B,
B: IntoFuture<Item = Self::Item>,
Self: Sized,
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>where
F: FnOnce(Self::Error) -> B,
B: IntoFuture<Item = Self::Item>,
Self: Sized,
source§fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
Self: Sized,
fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
Self: Sized,
source§fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
source§fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
Self: Sized,
source§fn join3<B, C>(
self,
b: B,
c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join3<B, C>(
self,
b: B,
c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.source§fn join4<B, C, D>(
self,
b: B,
c: C,
d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join4<B, C, D>(
self,
b: B,
c: C,
d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.source§fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. Read more