rt: update to actix-rt v2

This commit is contained in:
Rob Ede
2021-02-01 09:14:09 +00:00
committed by Ryan Leckey
parent cfe61a4724
commit e197d5b0e2
5 changed files with 18 additions and 48 deletions

View File

@@ -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 }

View File

@@ -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.")
};
}