Struct actix_net::server::Server [−][src]
pub struct Server { /* fields omitted */ }
Server
Methods
impl Server
[src]
impl Server
pub fn new() -> Server
[src]
pub fn new() -> Server
Create new Server instance
pub fn workers(self, num: usize) -> Self
[src]
pub fn workers(self, num: usize) -> Self
Set number of workers to start.
By default server uses number of available logical cpu as threads count.
pub fn maxconn(self, num: usize) -> Self
[src]
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.
pub fn system_exit(self) -> Self
[src]
pub fn system_exit(self) -> Self
Stop actix system.
SystemExit
message stops currently running system.
pub fn disable_signals(self) -> Self
[src]
pub fn disable_signals(self) -> Self
Disable signal handling
pub fn shutdown_timeout(self, sec: u16) -> Self
[src]
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.
pub fn configure<F>(self, cfg: F) -> Server where
F: Fn(Server) -> Server,
[src]
pub fn configure<F>(self, cfg: F) -> Server where
F: Fn(Server) -> Server,
Run external configuration as part of the server building process
This function is useful for moving parts of configuration to a different module or event library.
pub fn bind<F, U, N: AsRef<str>>(
self,
name: N,
addr: U,
factory: F
) -> Result<Self> where
F: StreamServiceFactory,
U: ToSocketAddrs,
[src]
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 server
pub fn listen<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Self where
F: StreamServiceFactory,
[src]
pub fn listen<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Self where
F: StreamServiceFactory,
Add new service to server
pub fn listen2<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Self where
F: ServiceFactory,
[src]
pub fn listen2<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F
) -> Self where
F: ServiceFactory,
Add new service to server
pub fn run(self)
[src]
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(); }
pub fn start(self) -> Addr<Server>
[src]
pub fn start(self) -> Addr<Server>
Starts Server Actor and returns its address
Trait Implementations
impl Default for Server
[src]
impl Default for Server
impl Actor for Server
[src]
impl Actor for Server
type Context = Context<Self>
Actor execution context type
fn started(&mut self, ctx: &mut Self::Context)
[src]
fn started(&mut self, ctx: &mut Self::Context)
Method is called when actor get polled first time.
fn stopping(&mut self, ctx: &mut Self::Context) -> Running
[src]
fn stopping(&mut self, ctx: &mut Self::Context) -> Running
Method is called after an actor is in Actor::Stopping
state. There could be several reasons for stopping. Context::stop
get called by the actor itself. All addresses to current actor get dropped and no more evented objects left in the context. Read more
fn stopped(&mut self, ctx: &mut Self::Context)
[src]
fn stopped(&mut self, ctx: &mut Self::Context)
Method is called after an actor is stopped, it can be used to perform any needed cleanup work or spawning more actors. This is final state, after this call actor get dropped. Read more
fn start(self) -> Addr<Self> where
Self: Actor<Context = Context<Self>>,
[src]
fn start(self) -> Addr<Self> where
Self: Actor<Context = Context<Self>>,
Start new asynchronous actor, returns address of newly created actor. Read more
fn start_default() -> Addr<Self> where
Self: Actor<Context = Context<Self>> + Default,
[src]
fn start_default() -> Addr<Self> where
Self: Actor<Context = Context<Self>> + Default,
Start new asynchronous actor, returns address of newly created actor.
fn create<F>(f: F) -> Addr<Self> where
F: FnOnce(&mut Context<Self>) -> Self + 'static,
Self: Actor<Context = Context<Self>>,
[src]
fn create<F>(f: F) -> Addr<Self> where
F: FnOnce(&mut Context<Self>) -> Self + 'static,
Self: Actor<Context = Context<Self>>,
Use create
method, if you need Context
object during actor initialization. Read more
impl Handler<Signal> for Server
[src]
impl Handler<Signal> for Server
Signals support
Handle SIGINT
, SIGTERM
, SIGQUIT
signals and stop actix system
message to System
actor.
type Result = ()
The type of value that this handle will return
fn handle(&mut self, msg: Signal, ctx: &mut Context<Self>)
[src]
fn handle(&mut self, msg: Signal, ctx: &mut Context<Self>)
Method is called for every message received by this Actor
impl Handler<PauseServer> for Server
[src]
impl Handler<PauseServer> for Server
type Result = ()
The type of value that this handle will return
fn handle(&mut self, _: PauseServer, _: &mut Context<Self>)
[src]
fn handle(&mut self, _: PauseServer, _: &mut Context<Self>)
Method is called for every message received by this Actor
impl Handler<ResumeServer> for Server
[src]
impl Handler<ResumeServer> for Server
type Result = ()
The type of value that this handle will return
fn handle(&mut self, _: ResumeServer, _: &mut Context<Self>)
[src]
fn handle(&mut self, _: ResumeServer, _: &mut Context<Self>)
Method is called for every message received by this Actor
impl Handler<StopServer> for Server
[src]
impl Handler<StopServer> for Server