Skip to main content

ServerConfiguration

Trait ServerConfiguration 

Source
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) { ... }
}
Expand description

Worker service configuration.

Required Associated Types§

Source

type Item: Send + 'static

Item dispatched to a worker service.

Source

type Service: Service<(), Self::Item, Res = (), Error = ()> + 'static

Service created independently for each worker.

Required Methods§

Source

async fn create(&self) -> Result<Self::Service>

Creates the service used by one worker.

Provided Methods§

Source

fn pause(&self)

Called when the server is paused.

Besides explicit Server::pause calls, the server pauses itself while no worker is available to accept items.

Source

fn resume(&self)

Called when the server is resumed.

Besides explicit Server::resume calls, the server resumes itself once a worker becomes available again.

Source

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.

Source

async fn stop(&self)

Performs asynchronous cleanup when the server stops.

Called once, before the workers are stopped.

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.

Source§

type Item = Connection

Source§

type Service = StreamService