Run artifact discover in sequential instead of in parallel (#1796)

* Perform artifact discovery in sequential

Run different `fetcher.find()` in sequential

* FuturesResolver: Fallback to other future if one error

* Fix typo

* Apply cargo fmt

* Parallelise `<QuickInstall as Fetcher>::find`

Check for signature in parallel to the package

* Download signature in `<QuickInstall as Fetcher>::find`

So that the signature download can be done in parallel.

* Bump msrv for binstalk-fetchers to 1.70

* Update crates/binstalk-fetchers/src/futures_resolver.rs

Co-authored-by: Félix Saparelli <felix@passcod.name>
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* cargo fmt

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Félix Saparelli <felix@passcod.name>
This commit is contained in:
Jiahao XU 2024-06-23 20:42:03 +10:00 committed by GitHub
parent ebdca1126e
commit ac7bac651d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 128 additions and 54 deletions

View file

@ -1,6 +1,11 @@
use std::sync::{
atomic::{AtomicBool, Ordering::Relaxed},
Once,
#![allow(unused)]
use std::{
future::Future,
sync::{
atomic::{AtomicBool, Ordering::Relaxed},
Once,
},
};
pub(super) use binstalk_downloader::{
@ -76,3 +81,33 @@ pub(super) async fn does_url_exist(
Ok(Box::pin(client.remote_gettable(url.clone())).await?)
}
#[derive(Debug)]
pub(super) struct AutoAbortJoinHandle<T>(JoinHandle<T>);
impl<T> AutoAbortJoinHandle<T>
where
T: Send + 'static,
{
pub(super) fn spawn<F>(future: F) -> Self
where
F: Future<Output = T> + Send + 'static,
{
Self(tokio::spawn(future))
}
}
impl<T> Drop for AutoAbortJoinHandle<T> {
fn drop(&mut self) {
self.0.abort();
}
}
impl<T, E> AutoAbortJoinHandle<Result<T, E>>
where
E: Into<FetchError>,
{
pub(super) async fn flattened_join(mut self) -> Result<T, FetchError> {
(&mut self.0).await?.map_err(Into::into)
}
}