From a3f165f9f43f6dd70f61ad6961805974810dcf89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Wed, 29 Jan 2020 13:08:20 +0100 Subject: [PATCH] Use blocking reqwest API in defer defer, or, trait functions such as it in general(?) cannot be async (yet) --- Cargo.lock | 1 + plume-common/Cargo.toml | 5 ++++- plume-common/src/activity_pub/inbox.rs | 3 ++- plume-models/Cargo.toml | 6 +++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd20617b..b8384f47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3180,6 +3180,7 @@ dependencies = [ "percent-encoding 2.1.0", "pin-project-lite", "serde", + "serde_json", "serde_urlencoded 0.6.1", "time", "tokio 0.2.20", diff --git a/plume-common/Cargo.toml b/plume-common/Cargo.toml index 6309fee2..d5b5f765 100644 --- a/plume-common/Cargo.toml +++ b/plume-common/Cargo.toml @@ -16,7 +16,6 @@ hex = "0.3" hyper = "0.13" openssl = "0.10.22" rocket = { git = "https://github.com/SergioBenitez/Rocket", rev = "async" } -reqwest = "0.10" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" @@ -32,3 +31,7 @@ version = "0.4" [dependencies.pulldown-cmark] default-features = false version = "0.2.0" + +[dependencies.reqwest] +features = ["json", "blocking"] +version = "0.10" diff --git a/plume-common/src/activity_pub/inbox.rs b/plume-common/src/activity_pub/inbox.rs index b04b4076..4d08e810 100644 --- a/plume-common/src/activity_pub/inbox.rs +++ b/plume-common/src/activity_pub/inbox.rs @@ -279,7 +279,8 @@ pub trait FromId: Sized { /// Dereferences an ID fn deref(id: &str) -> Result, Self::Error)> { - reqwest::ClientBuilder::new() + // Use blocking reqwest API here, since defer cannot be async (yet) + reqwest::blocking::Client::builder() .connect_timeout(std::time::Duration::from_secs(5)) .build() .map_err(|_| (None, InboxError::DerefError.into()))? diff --git a/plume-models/Cargo.toml b/plume-models/Cargo.toml index 8e22ec07..94b5c1a1 100644 --- a/plume-models/Cargo.toml +++ b/plume-models/Cargo.toml @@ -16,7 +16,6 @@ lazy_static = "1.0" migrations_internals= "1.4.0" openssl = "0.10.22" rocket = { git = "https://github.com/SergioBenitez/Rocket", rev = "async" } -reqwest = "0.10" scheduled-thread-pool = "0.2.2" serde = "1.0" serde_derive = "1.0" @@ -47,6 +46,11 @@ path = "../plume-common" [dependencies.plume-macro] path = "../plume-macro" +[dependencies.reqwest] +features = ["json", "blocking"] +version = "0.10" + + [dependencies.rocket_i18n] git = "https://github.com/Plume-org/rocket_i18n" branch = "go-async"