pub trait ConfigExt<ServerType, AcceptorType>where
    ServerType: Server + ?Sized,
{ fn port(&self) -> u16; fn host(&self) -> String; fn socket_addrs(&self) -> Vec<SocketAddr>; fn should_register_signals(&self) -> bool; fn nodelay(&self) -> bool; fn stopper(&self) -> Stopper; fn acceptor(&self) -> &AcceptorType; fn counter(&self) -> &CloneCounterNotable traits for CloneCounterimpl Future for CloneCounter type Output = ();; fn graceful_shutdown<'async_trait>(
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
        Self: 'async_trait
; fn handle_stream<'async_trait>(
        stream: ServerType::Transport,
        handler: impl 'async_trait + Handler
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
        Self: 'async_trait
; fn build_listener<Listener>(&self) -> Listener
        Listener: TryFrom<TcpListener>,
        <Listener as TryFrom<TcpListener>>::Error: Debug
; fn over_capacity(&self) -> bool; }
Expand description

Server-implementer interfaces to Config

These functions are intended for use by authors of trillium servers, and should not be necessary to build an application. Please open an issue if you find yourself using this trait directly in an application.

Required Methods

resolve a port for this application, either directly configured, from the environmental variable PORT, or a default of 8080

resolve the host for this application, either directly from configuration, from the HOST env var, or "localhost"

use the ConfigExt::port and ConfigExt::host to resolve a vec of potential socket addrs

returns whether this server should register itself for operating system signals. this flag does nothing aside from communicating to the server implementer that this is desired. defaults to true on cfg(unix) systems, and false elsewhere.

returns whether the server should set TCP_NODELAY on the TcpListener, if that is applicable

returns a clone of the Stopper associated with this server, to be used in conjunction with signals or other service interruption methods

returns the tls acceptor for this server

returns the CloneCounter for this server. please note that cloning this type has implications for graceful shutdown and needs to be done with care.

waits for the last clone of the CloneCounter in this config to drop, indicating that all outstanding requests are complete

apply the provided handler to the transport, using [trillium_http]’s http implementation. this is the default inner loop for most trillium servers

builds any type that is TryFromstd::net::TcpListener and configures it for use. most trillium servers should use this if possible instead of using ConfigExt::port, ConfigExt::host, or ConfigExt::socket_addrs.

this function also contains logic that sets nonblocking to true and on unix systems will build a tcp listener from the LISTEN_FD env var.

determines if the server is currently responding to more than the maximum number of connections set by Config::with_max_connections.