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

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

41
Cargo.lock generated
View file

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

View file

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

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