launchpad,put: run the pre-flight Launchpad checks concurrently
Each Launchpad API round trip costs a few hundred milliseconds of server processing, and put walked four of them sequentially (person, archive, published sources) before the connection came up: the slowest phase of the flow. The person and archive lookups are independent and now go out together; the three pre-flights (PPA info, target series, published versions) run as one join with results checked in the original order, so a missing PPA still reports the PPA error rather than the superseded check's.
This commit is contained in:
1 parent
d29894046e
commit
94eeea4842
1 file changed
+10
-10
+10
-10
@@ -207,11 +207,15 @@ pub async fn ppa_info(ppa: &str) -> Result<PpaInfo, Box<dyn Error>> {
|
||||
let (user, name) = split_ppa(ppa)?;
|
||||
let client = crate::distro_info::http_client();
|
||||
|
||||
let response = client
|
||||
.get(person_url(&user))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("cannot reach the Launchpad API: {e}"))?;
|
||||
// Two independent GETs, sent together: each Launchpad round trip
|
||||
// costs a few hundred milliseconds of server processing, and the
|
||||
// person lookup is only there to tell a missing user from a missing
|
||||
// PPA in the errors below
|
||||
let (person, archive) = tokio::join!(
|
||||
client.get(person_url(&user)).send(),
|
||||
client.get(archive_url(&user, &name)).send(),
|
||||
);
|
||||
let response = person.map_err(|e| format!("cannot reach the Launchpad API: {e}"))?;
|
||||
if response.status() == reqwest::StatusCode::NOT_FOUND {
|
||||
return Err(format!(
|
||||
"Launchpad user '~{user}' does not exist: check the PPA argument '{ppa}'"
|
||||
@@ -225,11 +229,7 @@ pub async fn ppa_info(ppa: &str) -> Result<PpaInfo, Box<dyn Error>> {
|
||||
.into());
|
||||
}
|
||||
|
||||
let response = client
|
||||
.get(archive_url(&user, &name))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("cannot reach the Launchpad API: {e}"))?;
|
||||
let response = archive.map_err(|e| format!("cannot reach the Launchpad API: {e}"))?;
|
||||
match response.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
let info: PpaInfo = response
|
||||
|
||||
Reference in new issue
Block a user