Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: alias actix-* features to their equivalent tokio-* features #1679

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ runtime-async-std = []
runtime-tokio = []

# actual runtimes
runtime-actix-native-tls = [
"sqlx-core/runtime-actix-native-tls",
"sqlx-macros/runtime-actix-native-tls",
"_rt-actix",
]
runtime-actix-native-tls = ["runtime-tokio-native-tls"]
runtime-async-std-native-tls = [
"sqlx-core/runtime-async-std-native-tls",
"sqlx-macros/runtime-async-std-native-tls",
Expand All @@ -91,11 +87,7 @@ runtime-tokio-native-tls = [
"_rt-tokio",
]

runtime-actix-rustls = [
"sqlx-core/runtime-actix-rustls",
"sqlx-macros/runtime-actix-rustls",
"_rt-actix",
]
runtime-actix-rustls = ["runtime-tokio-rustls"]
runtime-async-std-rustls = [
"sqlx-core/runtime-async-std-rustls",
"sqlx-macros/runtime-async-std-rustls",
Expand All @@ -108,7 +100,6 @@ runtime-tokio-rustls = [
]

# for conditional compilation
_rt-actix = []
_rt-async-std = []
_rt-tokio = []

Expand Down
10 changes: 2 additions & 8 deletions sqlx-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ edition = "2021"
publish = false

[features]
runtime-actix-native-tls = [
"sqlx/runtime-actix-native-tls",
"sqlx-rt/runtime-actix-native-tls",
]
runtime-actix-native-tls = ["runtime-tokio-native-tls"]
runtime-async-std-native-tls = [
"sqlx/runtime-async-std-native-tls",
"sqlx-rt/runtime-async-std-native-tls",
Expand All @@ -19,10 +16,7 @@ runtime-tokio-native-tls = [
"sqlx-rt/runtime-tokio-native-tls",
]

runtime-actix-rustls = [
"sqlx/runtime-actix-rustls",
"sqlx-rt/runtime-actix-rustls",
]
runtime-actix-rustls = ["runtime-tokio-rustls"]
runtime-async-std-rustls = [
"sqlx/runtime-async-std-rustls",
"sqlx-rt/runtime-async-std-rustls",
Expand Down
15 changes: 2 additions & 13 deletions sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ decimal = ["rust_decimal", "num-bigint"]
json = ["serde", "serde_json"]

# runtimes
runtime-actix-native-tls = [
"sqlx-rt/runtime-actix-native-tls",
"sqlx/runtime-actix-native-tls",
"_tls-native-tls",
"_rt-actix",
]
runtime-actix-native-tls = ["runtime-tokio-native-tls"]
runtime-async-std-native-tls = [
"sqlx-rt/runtime-async-std-native-tls",
"sqlx/runtime-async-std-native-tls",
Expand All @@ -84,12 +79,7 @@ runtime-tokio-native-tls = [
"_rt-tokio",
]

runtime-actix-rustls = [
"sqlx-rt/runtime-actix-rustls",
"sqlx/runtime-actix-rustls",
"_tls-rustls",
"_rt-actix"
]
runtime-actix-rustls = ['runtime-tokio-rustls']
runtime-async-std-rustls = [
"sqlx-rt/runtime-async-std-rustls",
"sqlx/runtime-async-std-rustls",
Expand All @@ -104,7 +94,6 @@ runtime-tokio-rustls = [
]

# for conditional compilation
_rt-actix = ["tokio-stream"]
_rt-async-std = []
_rt-tokio = ["tokio-stream"]
_tls-native-tls = []
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/migrate/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'s> MigrationSource<'s> for &'s Path {
let mut s = fs::read_dir(self.canonicalize()?).await?;
let mut migrations = Vec::new();

#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
#[cfg(feature = "_rt-tokio")]
let mut s = tokio_stream::wrappers::ReadDirStream::new(s);

while let Some(entry) = s.try_next().await? {
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/mssql/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Connection for MssqlConnection {
ready(self.stream.shutdown(Shutdown::Both).map_err(Into::into)).boxed()
}

#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
#[cfg(feature = "_rt-tokio")]
{
use sqlx_rt::AsyncWriteExt;

Expand Down
4 changes: 2 additions & 2 deletions sqlx-core/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ pub use tls::{CertificateInput, MaybeTlsStream};
#[cfg(feature = "_rt-async-std")]
type PollReadBuf<'a> = [u8];

#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
#[cfg(feature = "_rt-tokio")]
type PollReadBuf<'a> = sqlx_rt::ReadBuf<'a>;

#[cfg(feature = "_rt-async-std")]
type PollReadOut = usize;

#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
#[cfg(feature = "_rt-tokio")]
type PollReadOut = ();
4 changes: 2 additions & 2 deletions sqlx-core/src/net/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Socket {
}
}

#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
#[cfg(feature = "_rt-tokio")]
{
use sqlx_rt::AsyncWriteExt;

Expand Down Expand Up @@ -103,7 +103,7 @@ impl AsyncWrite for Socket {
}
}

#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
#[cfg(feature = "_rt-tokio")]
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match &mut *self {
Socket::Tcp(s) => Pin::new(s).poll_shutdown(cx),
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/net/tls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ where
}
}

#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
#[cfg(feature = "_rt-tokio")]
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match &mut *self {
MaybeTlsStream::Raw(s) => Pin::new(s).poll_shutdown(cx),
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/postgres/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
loop {
let read = match () {
// Tokio lets us read into the buffer without zeroing first
#[cfg(any(feature = "runtime-tokio", feature = "runtime-actix"))]
#[cfg(feature = "runtime-tokio")]
_ if buf.len() != buf.capacity() => {
// in case we have some data in the buffer, which can occur
// if the previous write did not fill the buffer
Expand Down
13 changes: 2 additions & 11 deletions sqlx-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ default = ["runtime-async-std-native-tls", "migrate"]
migrate = ["sha2", "sqlx-core/migrate"]

# runtimes
runtime-actix-native-tls = [
"sqlx-core/runtime-actix-native-tls",
"sqlx-rt/runtime-actix-native-tls",
"_rt-actix",
]
runtime-actix-native-tls = ["runtime-tokio-native-tls"]
runtime-async-std-native-tls = [
"sqlx-core/runtime-async-std-native-tls",
"sqlx-rt/runtime-async-std-native-tls",
Expand All @@ -36,11 +32,7 @@ runtime-tokio-native-tls = [
"_rt-tokio",
]

runtime-actix-rustls = [
"sqlx-core/runtime-actix-rustls",
"sqlx-rt/runtime-actix-rustls",
"_rt-actix",
]
runtime-actix-rustls = ["runtime-tokio-rustls"]
runtime-async-std-rustls = [
"sqlx-core/runtime-async-std-rustls",
"sqlx-rt/runtime-async-std-rustls",
Expand All @@ -53,7 +45,6 @@ runtime-tokio-rustls = [
]

# for conditional compilation
_rt-actix = []
_rt-async-std = []
_rt-tokio = []

Expand Down
9 changes: 0 additions & 9 deletions sqlx-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,6 @@ pub fn test(_attr: TokenStream, input: TokenStream) -> TokenStream {
::sqlx_rt::async_std::task::block_on(async { #body })
}
}
} else if cfg!(feature = "_rt-actix") {
quote! {
#[test]
#(#attrs)*
fn #name() #ret {
::sqlx_rt::actix_rt::System::new()
.block_on(async { #body })
}
}
} else {
panic!("one of 'runtime-actix', 'runtime-async-std' or 'runtime-tokio' features must be enabled");
};
Expand Down
6 changes: 2 additions & 4 deletions sqlx-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ authors = [
]

[features]
runtime-actix-native-tls = ["_rt-actix", "_tls-native-tls", "tokio-native-tls"]
runtime-actix-native-tls = ["runtime-tokio-native-tls"]
runtime-async-std-native-tls = [
"_rt-async-std",
"_tls-native-tls",
"async-native-tls",
]
runtime-tokio-native-tls = ["_rt-tokio", "_tls-native-tls", "tokio-native-tls"]

runtime-actix-rustls = ["_rt-actix", "_tls-rustls", "tokio-rustls"]
runtime-actix-rustls = ["runtime-tokio-rustls"]
runtime-async-std-rustls = ["_rt-async-std", "_tls-rustls", "futures-rustls"]
runtime-tokio-rustls = ["_rt-tokio", "_tls-rustls", "tokio-rustls"]

# Not used directly and not re-exported from sqlx
_rt-actix = ["actix-rt", "tokio", "once_cell"]
_rt-async-std = ["async-std"]
_rt-tokio = ["tokio", "once_cell"]
_tls-native-tls = ["native-tls"]
Expand All @@ -33,7 +32,6 @@ _tls-rustls = []
[dependencies]
async-native-tls = { version = "0.4.0", optional = true }
futures-rustls = { version = "0.22.0", optional = true }
actix-rt = { version = "2.0.0", default-features = false, optional = true }
async-std = { version = "1.7.0", features = ["unstable"], optional = true }
tokio-native-tls = { version = "0.3.0", optional = true }
tokio-rustls = { version = "0.23.0", optional = true }
Expand Down
Loading