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 backlog(self, num: i32) -> Self
pub fn backlog(self, num: i32) -> Self
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.
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 scrappy system.
Sourcepub fn disable_signals(self) -> Self
pub fn disable_signals(self) -> Self
Disable signal handling
Sourcepub fn shutdown_timeout(self, sec: u64) -> Self
pub fn shutdown_timeout(self, sec: u64) -> 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>
pub fn configure<F>(self, f: F) -> Result<ServerBuilder>
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>
pub fn bind<F, U, N: AsRef<str>>( self, name: N, addr: U, factory: F, ) -> Result<Self>
Add new service to the server.
Sourcepub fn bind_uds<F, U, N>(self, name: N, addr: U, factory: F) -> Result<Self>
pub fn bind_uds<F, U, N>(self, name: N, addr: U, factory: F) -> Result<Self>
Add new unix domain service to the server.
Sourcepub fn listen_uds<F, N: AsRef<str>>(
self,
name: N,
lst: UnixListener,
factory: F,
) -> Result<Self>where
F: ServiceFactory<UnixStream>,
pub fn listen_uds<F, N: AsRef<str>>(
self,
name: N,
lst: UnixListener,
factory: F,
) -> Result<Self>where
F: ServiceFactory<UnixStream>,
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.
Sourcepub fn listen<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F,
) -> Result<Self>where
F: ServiceFactory<TcpStream>,
pub fn listen<F, N: AsRef<str>>(
self,
name: N,
lst: TcpListener,
factory: F,
) -> Result<Self>where
F: ServiceFactory<TcpStream>,
Add new service to the server.
Trait Implementations§
Source§impl Default for ServerBuilder
impl Default for ServerBuilder
Source§impl Future for ServerBuilder
impl Future for ServerBuilder
Auto Trait Implementations§
impl Freeze for ServerBuilder
impl !RefUnwindSafe for ServerBuilder
impl Send for ServerBuilder
impl !Sync for ServerBuilder
impl Unpin for ServerBuilder
impl !UnwindSafe for ServerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
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. This method can be used to turn any Future
into a
FusedFuture
. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read moreSource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.Source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more