mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_udp: use features "with-glommio" and (default) "with-mio"
This commit is contained in:
parent
f69e3a00c7
commit
13d0224321
3 changed files with 24 additions and 8 deletions
|
|
@ -15,7 +15,9 @@ path = "src/lib/lib.rs"
|
||||||
name = "aquatic_udp"
|
name = "aquatic_udp"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
io_uring = ["glommio", "futures-lite"]
|
default = ["with-mio"]
|
||||||
|
with-glommio = ["glommio", "futures-lite"]
|
||||||
|
with-mio = ["crossbeam-channel", "histogram", "mio", "socket2"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
@ -24,20 +26,23 @@ aquatic_common = "0.1.0"
|
||||||
aquatic_udp_protocol = "0.1.0"
|
aquatic_udp_protocol = "0.1.0"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
core_affinity = "0.5"
|
core_affinity = "0.5"
|
||||||
crossbeam-channel = "0.5"
|
|
||||||
hashbrown = "0.11.2"
|
hashbrown = "0.11.2"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
histogram = "0.6"
|
|
||||||
indexmap = "1"
|
indexmap = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.11"
|
||||||
privdrop = "0.5"
|
privdrop = "0.5"
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
rand = { version = "0.8", features = ["small_rng"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
socket2 = { version = "0.4.1", features = ["all"] }
|
|
||||||
|
|
||||||
|
# mio
|
||||||
|
crossbeam-channel = { version = "0.5", optional = true }
|
||||||
|
histogram = { version = "0.6", optional = true }
|
||||||
|
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"], optional = true }
|
||||||
|
socket2 = { version = "0.4.1", features = ["all"], optional = true }
|
||||||
|
|
||||||
|
# glommio
|
||||||
glommio = { git = "https://github.com/DataDog/glommio.git", rev = "4e6b14772da2f4325271fbcf12d24cf91ed466e5", optional = true }
|
glommio = { git = "https://github.com/DataDog/glommio.git", rev = "4e6b14772da2f4325271fbcf12d24cf91ed466e5", optional = true }
|
||||||
futures-lite = { version = "1", optional = true }
|
futures-lite = { version = "1", optional = true }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ pub struct Config {
|
||||||
pub log_level: LogLevel,
|
pub log_level: LogLevel,
|
||||||
pub network: NetworkConfig,
|
pub network: NetworkConfig,
|
||||||
pub protocol: ProtocolConfig,
|
pub protocol: ProtocolConfig,
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
pub handlers: HandlerConfig,
|
pub handlers: HandlerConfig,
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
pub statistics: StatisticsConfig,
|
pub statistics: StatisticsConfig,
|
||||||
pub cleaning: CleaningConfig,
|
pub cleaning: CleaningConfig,
|
||||||
pub privileges: PrivilegeConfig,
|
pub privileges: PrivilegeConfig,
|
||||||
|
|
@ -52,6 +54,7 @@ pub struct NetworkConfig {
|
||||||
/// $ sudo sysctl -w net.core.rmem_max=104857600
|
/// $ sudo sysctl -w net.core.rmem_max=104857600
|
||||||
/// $ sudo sysctl -w net.core.rmem_default=104857600
|
/// $ sudo sysctl -w net.core.rmem_default=104857600
|
||||||
pub socket_recv_buffer_size: usize,
|
pub socket_recv_buffer_size: usize,
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
pub poll_event_capacity: usize,
|
pub poll_event_capacity: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,6 +69,7 @@ pub struct ProtocolConfig {
|
||||||
pub peer_announce_interval: i32,
|
pub peer_announce_interval: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct HandlerConfig {
|
pub struct HandlerConfig {
|
||||||
|
|
@ -75,6 +79,7 @@ pub struct HandlerConfig {
|
||||||
pub channel_recv_timeout_microseconds: u64,
|
pub channel_recv_timeout_microseconds: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct StatisticsConfig {
|
pub struct StatisticsConfig {
|
||||||
|
|
@ -119,7 +124,9 @@ impl Default for Config {
|
||||||
log_level: LogLevel::Error,
|
log_level: LogLevel::Error,
|
||||||
network: NetworkConfig::default(),
|
network: NetworkConfig::default(),
|
||||||
protocol: ProtocolConfig::default(),
|
protocol: ProtocolConfig::default(),
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
handlers: HandlerConfig::default(),
|
handlers: HandlerConfig::default(),
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
statistics: StatisticsConfig::default(),
|
statistics: StatisticsConfig::default(),
|
||||||
cleaning: CleaningConfig::default(),
|
cleaning: CleaningConfig::default(),
|
||||||
privileges: PrivilegeConfig::default(),
|
privileges: PrivilegeConfig::default(),
|
||||||
|
|
@ -133,8 +140,9 @@ impl Default for NetworkConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
address: SocketAddr::from(([0, 0, 0, 0], 3000)),
|
address: SocketAddr::from(([0, 0, 0, 0], 3000)),
|
||||||
poll_event_capacity: 4096,
|
|
||||||
socket_recv_buffer_size: 4096 * 128,
|
socket_recv_buffer_size: 4096 * 128,
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
|
poll_event_capacity: 4096,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,6 +157,7 @@ impl Default for ProtocolConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
impl Default for HandlerConfig {
|
impl Default for HandlerConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -158,6 +167,7 @@ impl Default for HandlerConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
impl Default for StatisticsConfig {
|
impl Default for StatisticsConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { interval: 0 }
|
Self { interval: 0 }
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ use cfg_if::cfg_if;
|
||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
#[cfg(all(feature = "io_uring", target_os = "linux"))]
|
#[cfg(all(feature = "with-glommio", target_os = "linux"))]
|
||||||
pub mod glommio;
|
pub mod glommio;
|
||||||
|
#[cfg(feature = "with-mio")]
|
||||||
pub mod mio;
|
pub mod mio;
|
||||||
|
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
|
@ -21,7 +22,7 @@ pub const APP_NAME: &str = "aquatic_udp: UDP BitTorrent tracker";
|
||||||
|
|
||||||
pub fn run(config: Config) -> ::anyhow::Result<()> {
|
pub fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(all(feature = "io_uring", target_os = "linux"))] {
|
if #[cfg(all(feature = "with-glommio", target_os = "linux"))] {
|
||||||
glommio::run(config)
|
glommio::run(config)
|
||||||
} else {
|
} else {
|
||||||
mio::run(config)
|
mio::run(config)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue