WIP: ws: put back mio implementation

This commit is contained in:
Joakim Frostegård 2021-11-05 12:42:55 +01:00
parent 8531e12d0e
commit 465cf5920d
19 changed files with 1559 additions and 266 deletions

View file

@ -20,10 +20,12 @@ pub struct Config {
pub log_level: LogLevel,
pub network: NetworkConfig,
pub protocol: ProtocolConfig,
pub handlers: HandlerConfig,
pub cleaning: CleaningConfig,
pub privileges: PrivilegeConfig,
pub access_list: AccessListConfig,
pub cpu_pinning: CpuPinningConfig,
pub statistics: StatisticsConfig,
}
impl aquatic_cli_helpers::Config for Config {
@ -38,10 +40,17 @@ pub struct NetworkConfig {
/// Bind to this address
pub address: SocketAddr,
pub ipv6_only: bool,
pub tls_certificate_path: PathBuf,
pub tls_private_key_path: PathBuf,
pub websocket_max_message_size: usize,
pub websocket_max_frame_size: usize,
pub use_tls: bool,
pub tls_pkcs12_path: String,
pub tls_pkcs12_password: String,
pub poll_event_capacity: usize,
pub poll_timeout_microseconds: u64,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
@ -55,6 +64,15 @@ pub struct ProtocolConfig {
pub peer_announce_interval: usize,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct HandlerConfig {
/// Maximum number of requests to receive from channel before locking
/// mutex and starting work
pub max_requests_per_iter: usize,
pub channel_recv_timeout_microseconds: u64,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct CleaningConfig {
@ -62,6 +80,16 @@ pub struct CleaningConfig {
pub torrent_cleaning_interval: u64,
/// Remove peers that haven't announced for this long (seconds)
pub max_peer_age: u64,
/// Remove connections that are older than this (seconds)
pub max_connection_age: u64,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct StatisticsConfig {
/// Print statistics this often (seconds). Don't print when set to zero.
pub interval: u64,
}
impl Default for Config {
@ -72,10 +100,12 @@ impl Default for Config {
log_level: LogLevel::default(),
network: NetworkConfig::default(),
protocol: ProtocolConfig::default(),
handlers: Default::default(),
cleaning: CleaningConfig::default(),
privileges: PrivilegeConfig::default(),
access_list: AccessListConfig::default(),
cpu_pinning: Default::default(),
statistics: Default::default(),
}
}
}
@ -89,6 +119,12 @@ impl Default for NetworkConfig {
tls_private_key_path: "".into(),
websocket_max_message_size: 64 * 1024,
websocket_max_frame_size: 16 * 1024,
use_tls: false,
tls_pkcs12_path: "".into(),
tls_pkcs12_password: "".into(),
poll_event_capacity: 4096,
poll_timeout_microseconds: 200_000,
}
}
}
@ -103,11 +139,28 @@ impl Default for ProtocolConfig {
}
}
impl Default for HandlerConfig {
fn default() -> Self {
Self {
max_requests_per_iter: 10000,
channel_recv_timeout_microseconds: 200,
}
}
}
impl Default for CleaningConfig {
fn default() -> Self {
Self {
torrent_cleaning_interval: 30,
max_peer_age: 1800,
max_connection_age: 1800,
}
}
}
impl Default for StatisticsConfig {
fn default() -> Self {
Self { interval: 0 }
}
}