Make requests to same instance in parallel
This commit is contained in:
parent
27c23bd5d8
commit
342fe6ded8
1 changed files with 7 additions and 14 deletions
21
src/main.rs
21
src/main.rs
|
@ -1,4 +1,5 @@
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
|
use futures::try_join;
|
||||||
use lemmy_stats_crawler::federated_instances::GetSiteResponse;
|
use lemmy_stats_crawler::federated_instances::GetSiteResponse;
|
||||||
use lemmy_stats_crawler::node_info::NodeInfo;
|
use lemmy_stats_crawler::node_info::NodeInfo;
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
|
@ -97,22 +98,14 @@ async fn fetch_instance_details(domain: &str) -> Result<InstanceDetails, Error>
|
||||||
let timeout = Duration::from_secs(10);
|
let timeout = Duration::from_secs(10);
|
||||||
|
|
||||||
let node_info_url = format!("https://{}/nodeinfo/2.0.json", domain);
|
let node_info_url = format!("https://{}/nodeinfo/2.0.json", domain);
|
||||||
let node_info: NodeInfo = client
|
let node_info_request = client.get(&node_info_url).timeout(timeout).send();
|
||||||
.get(&node_info_url)
|
|
||||||
.timeout(timeout)
|
|
||||||
.send()
|
|
||||||
.await?
|
|
||||||
.json()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let site_info_url = format!("https://{}/api/v2/site", domain);
|
let site_info_url = format!("https://{}/api/v2/site", domain);
|
||||||
let site_info: GetSiteResponse = client
|
let site_info_request = client.get(&site_info_url).timeout(timeout).send();
|
||||||
.get(&site_info_url)
|
|
||||||
.timeout(timeout)
|
let (node_info, site_info) = try_join!(node_info_request, site_info_request)?;
|
||||||
.send()
|
let node_info: NodeInfo = node_info.json().await?;
|
||||||
.await?
|
let site_info: GetSiteResponse = site_info.json().await?;
|
||||||
.json()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let linked_instances = site_info
|
let linked_instances = site_info
|
||||||
.federated_instances
|
.federated_instances
|
||||||
|
|
Loading…
Reference in a new issue