refactor: make globals simple
This commit is contained in:
parent
b5a6509ddb
commit
80e10d5ccd
4 changed files with 37 additions and 19 deletions
|
|
@ -6,25 +6,24 @@ use std::sync::{
|
|||
};
|
||||
use tokio::time::Duration;
|
||||
|
||||
/// Global object containing proxy configurations and shared object like counters.
|
||||
/// But note that in Globals, we do not have Mutex and RwLock. It is indeed, the context shared among async tasks.
|
||||
pub struct Globals {
|
||||
pub listen_sockets: Vec<SocketAddr>,
|
||||
pub http_port: Option<u16>,
|
||||
pub https_port: Option<u16>,
|
||||
pub listen_sockets: Vec<SocketAddr>, // when instantiate server
|
||||
pub http_port: Option<u16>, // when instantiate server
|
||||
pub https_port: Option<u16>, // when instantiate server
|
||||
|
||||
pub proxy_timeout: Duration,
|
||||
pub upstream_timeout: Duration,
|
||||
pub proxy_timeout: Duration, // when serving requests at Proxy
|
||||
pub upstream_timeout: Duration, // when serving requests at Handler
|
||||
|
||||
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,
|
||||
pub max_clients: usize, // when serving requests
|
||||
pub max_concurrent_streams: u32, // when instantiate server
|
||||
pub keepalive: bool, // when instantiate server
|
||||
|
||||
// experimentals
|
||||
pub sni_consistency: bool,
|
||||
pub sni_consistency: bool, // Handler
|
||||
|
||||
// All need to make packet acceptor
|
||||
#[cfg(feature = "http3")]
|
||||
pub http3: bool,
|
||||
#[cfg(feature = "http3")]
|
||||
|
|
@ -39,9 +38,22 @@ pub struct Globals {
|
|||
pub h3_max_concurrent_connections: u32,
|
||||
#[cfg(feature = "http3")]
|
||||
pub h3_max_idle_timeout: Option<quinn::IdleTimeout>,
|
||||
|
||||
// Shared context
|
||||
// Backend application objects to which http request handler forward incoming requests
|
||||
pub backends: Backends,
|
||||
// Counter for serving requests
|
||||
pub request_count: RequestCount,
|
||||
// Async task runtime handler
|
||||
pub runtime_handle: tokio::runtime::Handle,
|
||||
}
|
||||
|
||||
// // TODO: Implement default for default values
|
||||
// #[derive(Debug, Clone)]
|
||||
// pub struct ProxyConfig {}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
/// Counter for serving requests
|
||||
pub struct RequestCount(Arc<AtomicUsize>);
|
||||
|
||||
impl RequestCount {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue