servlet 1.1.0

A small application runtime with an explicit operational contract
Documentation
//! Initial configuration profile from the runtime design.

use std::net::{Ipv4Addr, SocketAddr};
use std::time::Duration;

/// Runtime settings; validation does not start infrastructure.
///
/// Initial defaults target bounded HTTP APIs behind a trusted ingress.
///
/// Start from the defaults and set fields before passing the settings to
/// [`crate::App::config`]. To override the environment, use
/// [`crate::App::configure`] instead.
///
/// ```
/// use servlet::{App, AppConfig};
///
/// let mut config = AppConfig::default();
/// config.max_in_flight = 32;
/// let _app: App = App::new("orders").config(config);
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct AppConfig {
    /// Application listener address. Port zero allows OS port assignment.
    pub bind: SocketAddr,
    /// Separate administrative listener, disabled by default.
    pub admin_bind: Option<SocketAddr>,
    /// Explicitly permit an administrative listener on a non-loopback address.
    pub allow_remote_admin: bool,
    /// Maximum request body size in bytes.
    pub request_body_limit: usize,
    /// Maximum globally admitted exchanges, including active response bodies.
    pub max_in_flight: usize,
    /// Maximum live HTTP connections, independently of exchange admission.
    pub max_connections: usize,
    /// Maximum time to read a complete request header block.
    pub header_timeout: Duration,
    /// Maximum idle time waiting for a request/response body frame or socket write.
    pub body_idle_timeout: Duration,
    /// Total budget for an admitted request, including response transfer.
    pub request_timeout: Duration,
    /// Total startup budget.
    pub startup_timeout: Duration,
    /// Total application shutdown budget for draining, cancellation, and registered cleanup.
    ///
    /// [Process bootstrap](crate::process::Bootstrap::block_on) has separate allowances
    /// for telemetry flushing and executor teardown.
    pub shutdown_timeout: Duration,
    /// Portion of the application shutdown budget reserved for cancellation and cleanup.
    pub cleanup_reserve: Duration,
}

impl Default for AppConfig {
    fn default() -> Self {
        Self {
            bind: SocketAddr::from((Ipv4Addr::LOCALHOST, 8080)),
            admin_bind: None,
            allow_remote_admin: false,
            request_body_limit: 1024 * 1024,
            max_in_flight: 128,
            max_connections: 256,
            header_timeout: Duration::from_secs(5),
            body_idle_timeout: Duration::from_secs(10),
            request_timeout: Duration::from_secs(30),
            startup_timeout: Duration::from_secs(30),
            shutdown_timeout: Duration::from_secs(25),
            cleanup_reserve: Duration::from_secs(5),
        }
    }
}

#[cfg(test)]
#[path = "settings_test.rs"]
mod settings_test;