mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 21:37:58 +03:00
Refactor features
This commit is contained in:
parent
db16b71c5f
commit
3cc7883da5
6 changed files with 33 additions and 65 deletions
|
@ -77,5 +77,6 @@ windows-sys = { workspace = true, features = ["Win32_UI_WindowsAndMessaging"] }
|
|||
cfg_aliases = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["polling"]
|
||||
default = []
|
||||
polling = ["dep:polling"]
|
||||
io-uring = ["dep:io-uring"]
|
||||
|
|
|
@ -25,10 +25,10 @@ tokio = ["ntex-rt/tokio", "ntex-tokio"]
|
|||
compio = ["ntex-rt/compio", "ntex-compio"]
|
||||
|
||||
# neon runtime
|
||||
neon = ["ntex-rt/neon", "ntex-neon/polling", "slab", "socket2"]
|
||||
neon = ["ntex-rt/neon", "ntex-neon", "slab", "socket2"]
|
||||
|
||||
# neon io-uring runtime
|
||||
neon-uring = ["ntex-rt/neon", "ntex-neon/io-uring", "io-uring", "slab", "socket2"]
|
||||
polling = ["ntex-neon/polling", "dep:polling"]
|
||||
io-uring = ["ntex-neon/io-uring", "dep:io-uring"]
|
||||
|
||||
[dependencies]
|
||||
ntex-service = "3.3"
|
||||
|
@ -43,15 +43,17 @@ ntex-compio = { version = "0.2.4", optional = true }
|
|||
ntex-neon = { version = "0.1.0", optional = true }
|
||||
|
||||
bitflags = { workspace = true }
|
||||
cfg-if = { workspace = true }
|
||||
log = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
slab = { workspace = true, optional = true }
|
||||
socket2 = { workspace = true, optional = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
# Linux specific dependencies
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
io-uring = { workspace = true, optional = true }
|
||||
polling = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
ntex = "2"
|
||||
|
|
|
@ -6,51 +6,18 @@ pub use ntex_tokio::{from_tcp_stream, tcp_connect, tcp_connect_in};
|
|||
#[cfg(all(unix, feature = "tokio"))]
|
||||
pub use ntex_tokio::{from_unix_stream, unix_connect, unix_connect_in};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "neon",
|
||||
not(feature = "neon-uring"),
|
||||
not(feature = "tokio"),
|
||||
not(feature = "compio")
|
||||
))]
|
||||
pub use crate::rt_polling::{
|
||||
from_tcp_stream, from_unix_stream, tcp_connect, tcp_connect_in, unix_connect,
|
||||
unix_connect_in,
|
||||
};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "neon-uring",
|
||||
not(feature = "neon"),
|
||||
not(feature = "tokio"),
|
||||
not(feature = "compio")
|
||||
))]
|
||||
pub use crate::rt_uring::{
|
||||
from_tcp_stream, from_unix_stream, tcp_connect, tcp_connect_in, unix_connect,
|
||||
unix_connect_in,
|
||||
};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "compio",
|
||||
not(feature = "tokio"),
|
||||
not(feature = "neon"),
|
||||
not(feature = "neon-uring")
|
||||
))]
|
||||
#[cfg(all(feature = "compio", not(feature = "tokio"), not(feature = "neon")))]
|
||||
pub use ntex_compio::{from_tcp_stream, tcp_connect, tcp_connect_in};
|
||||
|
||||
#[cfg(all(
|
||||
unix,
|
||||
feature = "compio",
|
||||
not(feature = "tokio"),
|
||||
not(feature = "neon"),
|
||||
not(feature = "neon-uring")
|
||||
not(feature = "neon")
|
||||
))]
|
||||
pub use ntex_compio::{from_unix_stream, unix_connect, unix_connect_in};
|
||||
|
||||
#[cfg(all(
|
||||
not(feature = "tokio"),
|
||||
not(feature = "compio"),
|
||||
not(feature = "neon"),
|
||||
not(feature = "neon-uring")
|
||||
))]
|
||||
#[cfg(all(not(feature = "tokio"), not(feature = "compio"), not(feature = "neon")))]
|
||||
mod no_rt {
|
||||
use ntex_io::Io;
|
||||
|
||||
|
@ -115,10 +82,5 @@ mod no_rt {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
not(feature = "tokio"),
|
||||
not(feature = "compio"),
|
||||
not(feature = "neon"),
|
||||
not(feature = "neon-uring")
|
||||
))]
|
||||
#[cfg(all(not(feature = "tokio"), not(feature = "compio"), not(feature = "neon")))]
|
||||
pub use no_rt::*;
|
||||
|
|
|
@ -8,20 +8,22 @@ pub mod connect;
|
|||
pub use ntex_io::Io;
|
||||
pub use ntex_rt::{spawn, spawn_blocking};
|
||||
|
||||
pub use self::compat::*;
|
||||
|
||||
#[cfg(all(
|
||||
feature = "neon",
|
||||
not(feature = "neon-uring"),
|
||||
not(feature = "tokio"),
|
||||
not(feature = "compio")
|
||||
))]
|
||||
mod rt_polling;
|
||||
|
||||
#[cfg(all(
|
||||
feature = "neon-uring",
|
||||
not(feature = "neon"),
|
||||
not(feature = "tokio"),
|
||||
not(feature = "compio")
|
||||
))]
|
||||
mod rt_uring;
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(feature = "neon", target_os = "linux", feature = "io-uring"))] {
|
||||
#[path = "rt_uring/mod.rs"]
|
||||
mod rt_impl;
|
||||
pub use self::rt_impl::{
|
||||
from_tcp_stream, from_unix_stream, tcp_connect, tcp_connect_in, unix_connect,
|
||||
unix_connect_in,
|
||||
};
|
||||
} else if #[cfg(all(unix, feature = "neon"))] {
|
||||
#[path = "rt_polling/mod.rs"]
|
||||
mod rt_impl;
|
||||
pub use self::rt_impl::{
|
||||
from_tcp_stream, from_unix_stream, tcp_connect, tcp_connect_in, unix_connect,
|
||||
unix_connect_in,
|
||||
};
|
||||
} else {
|
||||
pub use self::compat::*;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ compio = ["ntex-net/compio"]
|
|||
neon = ["ntex-net/neon"]
|
||||
|
||||
# neon runtime
|
||||
neon-uring = ["ntex-net/neon-uring"]
|
||||
neon-uring = ["ntex-net/neon", "ntex-net/io-uring"]
|
||||
|
||||
# websocket support
|
||||
ws = ["dep:sha-1"]
|
||||
|
|
|
@ -21,6 +21,7 @@ async fn service(msg: ws::Frame) -> Result<Option<ws::Message>, io::Error> {
|
|||
|
||||
#[ntex::test]
|
||||
async fn web_ws() {
|
||||
env_logger::try_init();
|
||||
let srv = test::server(|| {
|
||||
App::new().service(web::resource("/").route(web::to(
|
||||
|req: HttpRequest| async move {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue