pub struct Server<T> { /* private fields */ }Expand description
Controller and completion future for a running server.
Clones can pause, resume, stop, or submit items to the server. Awaiting a
Server resolves when the server has stopped. It always resolves to
Ok(()).
Implementations§
Source§impl Server<Connection>
impl Server<Connection>
Sourcepub fn builder() -> ServerBuilder
pub fn builder() -> ServerBuilder
Creates a network server builder with no application configuration.
Source§impl<T> Server<T>
impl<T> Server<T>
Sourcepub fn process(&self, item: T) -> Result<(), T>
pub fn process(&self, item: T) -> Result<(), T>
Submits an item to the worker pool.
Returns the item unchanged if the server is paused or cannot accept it.
The server starts paused and resumes once the first worker is ready. It also pauses itself while no worker is available, so items submitted right after start or during worker restarts may be rejected.
Sourcepub fn pause(&self) -> impl Future<Output = ()> + use<T>
pub fn pause(&self) -> impl Future<Output = ()> + use<T>
Pauses processing new items.
For network servers, listeners stop accepting connections, so new connections wait in the kernel listen backlog. Existing connections remain active.
Sourcepub fn stop(&self, graceful: bool) -> impl Future<Output = ()> + use<T>
pub fn stop(&self, graceful: bool) -> impl Future<Output = ()> + use<T>
Stops processing new items and shuts down all workers.
If graceful is true, workers are given up to the graceful shutdown
timeout to finish active work before they are stopped. A zero timeout
makes the stop non-graceful.
The returned future resolves once the stop has completed. If the server has already stopped, it resolves immediately.