Skip to content

Commit ffdb0a8

Browse files
committed
Let resolver be async
1 parent fe1c026 commit ffdb0a8

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

murek/src/ops/resolve.rs

+23-20
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,32 @@ pub struct WorkspaceResolution {
2222
fields(root = ws.root().display().to_string())
2323
)]
2424
pub fn resolve_workspace(ws: &Workspace<'_>) -> Result<WorkspaceResolution> {
25-
let registry = Registry::preloaded(ws.members(), ws.config());
26-
let mut registry_cache = RegistryCache::new(registry);
27-
28-
let members_summaries = ws
29-
.members()
30-
.map(|pkg| pkg.manifest.summary.clone())
31-
.collect::<Vec<_>>();
32-
33-
let resolve = resolver::resolve(&members_summaries, &mut registry_cache, ws.config())?;
34-
35-
// Gather [`Package`] instances from this resolver result, by asking the [`RegistryCache`]
36-
// to download resolved packages.
37-
//
38-
// Currently, it is expected that all packages are already downloaded during resolution,
39-
// so the `download` calls in this method should be cheap, but this may change the future.
40-
let packages =
41-
async_collect_packages_from_resolve_graph(&resolve, &mut registry_cache).await_sync()?;
42-
43-
Ok(WorkspaceResolution { resolve, packages })
25+
async {
26+
let registry = Registry::preloaded(ws.members(), ws.config());
27+
let mut registry_cache = RegistryCache::new(registry);
28+
29+
let members_summaries = ws
30+
.members()
31+
.map(|pkg| pkg.manifest.summary.clone())
32+
.collect::<Vec<_>>();
33+
34+
let resolve =
35+
resolver::resolve(&members_summaries, &mut registry_cache, ws.config()).await?;
36+
37+
// Gather [`Package`] instances from this resolver result, by asking the [`RegistryCache`]
38+
// to download resolved packages.
39+
//
40+
// Currently, it is expected that all packages are already downloaded during resolution,
41+
// so the `download` calls in this method should be cheap, but this may change the future.
42+
let packages = collect_packages_from_resolve_graph(&resolve, &mut registry_cache).await?;
43+
44+
Ok(WorkspaceResolution { resolve, packages })
45+
}
46+
.await_sync()
4447
}
4548

4649
#[tracing::instrument(level = "trace", skip_all)]
47-
async fn async_collect_packages_from_resolve_graph(
50+
async fn collect_packages_from_resolve_graph(
4851
resolve: &Resolve,
4952
registry: &mut RegistryCache<'_>,
5053
) -> Result<HashMap<PackageId, Package>> {

murek/src/resolver/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use petgraph::graphmap::DiGraphMap;
66
use crate::core::registry::cache::RegistryCache;
77
use crate::core::resolver::Resolve;
88
use crate::core::{Config, PackageId, Summary};
9-
use crate::internal::asyncx::AwaitSync;
109

1110
/// Builds the list of all packages required to build the first argument.
1211
///
@@ -22,7 +21,7 @@ use crate::internal::asyncx::AwaitSync;
2221
///
2322
/// * `config` - [`Config`] object.
2423
#[tracing::instrument(level = "trace", skip_all)]
25-
pub fn resolve(
24+
pub async fn resolve(
2625
summaries: &[Summary],
2726
registry: &mut RegistryCache<'_>,
2827
_config: &Config,
@@ -53,7 +52,7 @@ pub fn resolve(
5352
continue;
5453
}
5554

56-
let results = registry.query(&dep).await_sync()?;
55+
let results = registry.query(&dep).await?;
5756

5857
let dep_summary = results
5958
.first()

0 commit comments

Comments
 (0)