pub trait ServerConfiguration:
Send
+ Clone
+ 'static {
type Item: Send + 'static;
type Service: Service<(), Self::Item, Res = (), Error = ()> + 'static;
// Required method
async fn create(&self) -> Result<Self::Service>;
// Provided methods
fn pause(&self) { ... }
fn resume(&self) { ... }
fn terminate(&self) { ... }
async fn stop(&self) { ... }
fn incoming_cpu(&self, item: &Self::Item) -> Option<usize> { ... }
}Expand description
Worker service configuration.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn pause(&self)
fn pause(&self)
Called when the server status changes from
Ready to paused or unavailable.
The server is paused by Server::pause, and it is unavailable
while no worker can accept items. Not called when the server stops.
Sourcefn resume(&self)
fn resume(&self)
Called when the server status becomes Ready.
The server is ready while it is not paused and a worker is available.
Sourcefn terminate(&self)
fn terminate(&self)
Called when the server’s command loop exits.
This happens after a stop requested through Server::stop or a
signal, graceful or not, once stop has completed.
Sourceasync fn stop(&self)
async fn stop(&self)
Performs asynchronous cleanup when the server stops.
Called once, before the workers are stopped.
Sourcefn incoming_cpu(&self, item: &Self::Item) -> Option<usize>
fn incoming_cpu(&self, item: &Self::Item) -> Option<usize>
Returns the index of the logical CPU that receives the network packets of the item, if known.
Used by LoadBalancing::IncomingCpu to send the item to the worker
placed on that CPU. CPUs are numbered as in Worker::start. Network
servers return the receive-side scaling (RSS) CPU of the connection on
Windows, and its SO_INCOMING_CPU on Linux and Android. The default
returns None.
Called on the thread that submits the item with Server::process,
e.g. the accept thread of a network server.
Calls are not concurrent. An item submitted while the method runs,
e.g. by the method itself, is sent without its incoming CPU.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<Cfg: ServerAppConfig> ServerConfiguration for StreamServer<Cfg>
Worker service factory.
impl<Cfg: ServerAppConfig> ServerConfiguration for StreamServer<Cfg>
Worker service factory.