Skip to content

Commit

Permalink
ls-remote: fetch versions in parallel (#1119)
Browse files Browse the repository at this point in the history
* ls-remote: fetch versions in parallel

* lint dockerfile
  • Loading branch information
jdx authored Dec 8, 2023
1 parent e1d2ff9 commit ac8b490
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions packaging/rtx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM ubuntu:22.04
LABEL maintainer="jdx"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ENV RTX_DATA_DIR="/rtx"
ENV RTX_CONFIG_DIR="/rtx"
Expand Down
17 changes: 13 additions & 4 deletions src/cli/ls_remote.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::Arc;

use color_eyre::eyre::Result;
use rayon::prelude::*;

use crate::cli::args::tool::ToolArg;
use crate::cli::args::tool::ToolArgParser;
Expand Down Expand Up @@ -65,10 +66,18 @@ impl LsRemote {
}

fn run_all(self, config: Config, out: &mut Output) -> Result<()> {
for plugin in config.plugins.values() {
let versions = plugin.list_remote_versions(&config.settings)?;
for version in versions {
rtxprintln!(out, "{}@{}", plugin.name(), version);
let versions = config
.plugins
.values()
.par_bridge()
.map(|p| {
let versions = p.list_remote_versions(&config.settings)?;
Ok((p, versions))
})
.collect::<Result<Vec<_>>>()?;
for (plugin, versions) in versions {
for v in versions {
rtxprintln!(out, "{}@{v}", plugin);
}
}
Ok(())
Expand Down

0 comments on commit ac8b490

Please sign in to comment.