mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-01 16:42:55 +00:00
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:
parent
ebdca1126e
commit
ac7bac651d
7 changed files with 128 additions and 54 deletions
|
@ -1,5 +1,7 @@
|
|||
use std::{future::Future, pin::Pin};
|
||||
use std::{fmt::Debug, future::Future, pin::Pin};
|
||||
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::warn;
|
||||
|
||||
/// Given multiple futures with output = `Result<Option<T>, E>`,
|
||||
/// returns the the first one that returns either `Err(_)` or
|
||||
|
@ -17,7 +19,7 @@ impl<T, E> Default for FuturesResolver<T, E> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Send + 'static, E: Send + 'static> FuturesResolver<T, E> {
|
||||
impl<T: Send + 'static, E: Send + Debug + 'static> FuturesResolver<T, E> {
|
||||
/// Insert new future into this resolver, they will start running
|
||||
/// right away.
|
||||
pub fn push<Fut>(&self, fut: Fut)
|
||||
|
@ -67,10 +69,18 @@ impl<T: Send + 'static, E: Send + 'static> FuturesResolver<T, E> {
|
|||
}
|
||||
|
||||
/// Return the resolution.
|
||||
pub fn resolve(self) -> impl Future<Output = Result<Option<T>, E>> {
|
||||
pub fn resolve(self) -> impl Future<Output = Option<T>> {
|
||||
let mut rx = self.rx;
|
||||
drop(self.tx);
|
||||
|
||||
async move { rx.recv().await.transpose() }
|
||||
async move {
|
||||
loop {
|
||||
match rx.recv().await {
|
||||
Some(Ok(ret)) => return Some(ret),
|
||||
Some(Err(err)) => warn!(?err, "Fail to resolve the future"),
|
||||
None => return None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue