From e197d5b0e22fcab4ce2c0f1459319da4aaeff0ef Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 1 Feb 2021 09:14:09 +0000 Subject: [PATCH] rt: update to actix-rt v2 --- CHANGELOG.md | 8 +++++++- Cargo.lock | 41 +++-------------------------------------- sqlx-macros/src/lib.rs | 2 +- sqlx-rt/Cargo.toml | 5 ++--- sqlx-rt/src/lib.rs | 10 +++++----- 5 files changed, 18 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec39735c..ff187985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,13 +25,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [[#976]] Remove the `Done` trait. The `.rows_affected()` method is now available as an inherent method on `PgQueryResult`, `MySqlQueryResult` and so on. [[@jplatte]] -- [[#983]] Upgrade async runtime dependencies [[@seryl], [@ant32], [@jplatte]] +- [[#983]] [[#1022]] Upgrade async runtime dependencies [[@seryl], [@ant32], [@jplatte], [@robjtede]] - tokio 1.0 - actix-rt 2.0 - [[#1007]] Remove `any::AnyType` [[@jplatte]] +[#983]: https://github.com/launchbadge/sqlx/pull/983 +[#1022]: https://github.com/launchbadge/sqlx/pull/1022 + ## 0.4.2 - 2020-12-19 - [[#908]] Fix `whoami` crash on FreeBSD platform [[@fundon]] [[@AldaronLau]] @@ -782,3 +785,6 @@ Fix docs.rs build by enabling a runtime feature in the docs.rs metadata in `Carg [@dstoeckel]: https://github.com/dstoeckel [@mrcd]: https://github.com/mrcd [@dvermd]: https://github.com/dvermd +[@seryl]: https://github.com/seryl +[@ant32]: https://github.com/ant32 +[@robjtede]: https://github.com/robjtede diff --git a/Cargo.lock b/Cargo.lock index b9e4aa6f..ea8013f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,28 +2,14 @@ # It is not intended for manual editing. [[package]] name = "actix-rt" -version = "2.0.0-beta.2" +version = "2.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac24f3f660d4c394cc6d24272e526083c257d6045d3be76a9d0a76be5cb56515" +checksum = "eafee07c9b31438583683fadb545467456efa36509523c19ba096acaf1d5878c" dependencies = [ + "futures-core", "tokio", ] -[[package]] -name = "actix-threadpool" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d209f04d002854b9afd3743032a27b066158817965bf5d036824d19ac2cc0e30" -dependencies = [ - "derive_more", - "futures-channel", - "lazy_static", - "log", - "num_cpus", - "parking_lot", - "threadpool", -] - [[package]] name = "ahash" version = "0.4.7" @@ -677,17 +663,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "derive_more" -version = "0.99.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "dialoguer" version = "0.7.1" @@ -2407,7 +2382,6 @@ name = "sqlx-rt" version = "0.2.0" dependencies = [ "actix-rt", - "actix-threadpool", "async-native-tls", "async-rustls", "async-std", @@ -2665,15 +2639,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - [[package]] name = "time" version = "0.1.44" diff --git a/sqlx-macros/src/lib.rs b/sqlx-macros/src/lib.rs index d2a1a3ef..8956aa74 100644 --- a/sqlx-macros/src/lib.rs +++ b/sqlx-macros/src/lib.rs @@ -129,7 +129,7 @@ pub fn test(_attr: TokenStream, input: TokenStream) -> TokenStream { #[test] #(#attrs)* fn #name() #ret { - ::sqlx_rt::actix_rt::System::new("sqlx-test") + ::sqlx_rt::actix_rt::System::new() .block_on(async { #body }) } } diff --git a/sqlx-rt/Cargo.toml b/sqlx-rt/Cargo.toml index 3d639b2d..66b3b5d7 100644 --- a/sqlx-rt/Cargo.toml +++ b/sqlx-rt/Cargo.toml @@ -20,7 +20,7 @@ runtime-async-std-rustls = ["_rt-async-std", "_tls-rustls", "async-rustls"] runtime-tokio-rustls = ["_rt-tokio", "_tls-rustls", "tokio-rustls"] # Not used directly and not re-exported from sqlx -_rt-actix = ["actix-rt", "actix-threadpool", "tokio", "once_cell"] +_rt-actix = ["actix-rt", "tokio", "once_cell"] _rt-async-std = ["async-std"] _rt-tokio = ["tokio", "once_cell"] _tls-native-tls = ["native-tls"] @@ -29,8 +29,7 @@ _tls-rustls = [] [dependencies] async-native-tls = { version = "0.3.3", optional = true } async-rustls = { version = "0.2.0", optional = true } -actix-rt = { version = "=2.0.0-beta.2", default-features = false, optional = true } -actix-threadpool = { version = "0.3.2", 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.22.0", optional = true } diff --git a/sqlx-rt/src/lib.rs b/sqlx-rt/src/lib.rs index 54f35f3b..c71fcf33 100644 --- a/sqlx-rt/src/lib.rs +++ b/sqlx-rt/src/lib.rs @@ -114,7 +114,7 @@ macro_rules! blocking { // #[cfg(feature = "_rt-actix")] -pub use {actix_rt, actix_threadpool}; +pub use actix_rt; #[cfg(all( feature = "_rt-actix", @@ -123,10 +123,10 @@ pub use {actix_rt, actix_threadpool}; #[macro_export] macro_rules! blocking { ($($expr:tt)*) => { - $crate::actix_threadpool::run(move || { $($expr)* }).await.map_err(|err| match err { - $crate::actix_threadpool::BlockingError::Error(e) => e, - $crate::actix_threadpool::BlockingError::Canceled => panic!("{}", err) - }) + // spawn_blocking is a re-export from tokio + $crate::actix_rt::task::spawn_blocking(move || { $($expr)* }) + .await + .expect("Blocking task failed to complete.") }; }