use crate::backend::Backends; use std::net::SocketAddr; use std::sync::{ atomic::{AtomicUsize, Ordering}, Arc, }; use tokio::time::Duration; pub struct Globals { pub listen_sockets: Vec, pub http_port: Option, pub https_port: Option, pub proxy_timeout: Duration, pub upstream_timeout: Duration, pub max_clients: usize, pub request_count: RequestCount, pub max_concurrent_streams: u32, pub keepalive: bool, pub runtime_handle: tokio::runtime::Handle, pub backends: Backends, // experimentals pub sni_consistency: bool, #[cfg(feature = "http3")] pub http3: bool, #[cfg(feature = "http3")] pub h3_alt_svc_max_age: u32, #[cfg(feature = "http3")] pub h3_request_max_body_size: usize, #[cfg(feature = "http3")] pub h3_max_concurrent_bidistream: quinn::VarInt, #[cfg(feature = "http3")] pub h3_max_concurrent_unistream: quinn::VarInt, #[cfg(feature = "http3")] pub h3_max_concurrent_connections: u32, #[cfg(feature = "http3")] pub h3_max_idle_timeout: Option, } #[derive(Debug, Clone, Default)] pub struct RequestCount(Arc); impl RequestCount { pub fn current(&self) -> usize { self.0.load(Ordering::Relaxed) } pub fn increment(&self) -> usize { self.0.fetch_add(1, Ordering::Relaxed) } pub fn decrement(&self) -> usize { let mut count; while { count = self.0.load(Ordering::Relaxed); count > 0 && self .0 .compare_exchange(count, count - 1, Ordering::Relaxed, Ordering::Relaxed) != Ok(count) } {} count } }