Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cache mm-config-version-get #913

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions svc/pkg/mm-config/ops/version-get/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ async fn handle(
.map(common::Uuid::as_uuid)
.collect::<Vec<_>>();

let versions = fetch_versions(&ctx.base(), req_version_ids)
.await?
.into_iter()
.map(|x| x.1)
.collect::<Vec<_>>();

// TODO: There's a bug with this that returns the lobby groups for the wrong
// version, can't figure this out
// let versions = ctx
Expand All @@ -83,6 +77,30 @@ async fn handle(
// })
// .await?;

// HACK: Because fetch all doesn't work, we'll use fetch one
NathanFlurry marked this conversation as resolved.
Show resolved Hide resolved
let mut versions = Vec::new();
for version_id in req_version_ids {
let version = ctx
.cache()
.immutable()
.fetch_one_proto("versions2", version_id, |mut cache, req_version_id| {
let ctx = ctx.base();

async move {
let versions = fetch_versions(&ctx.base(), vec![req_version_id]).await?;
ensure!(versions.len() <= 1, "too many versions");
if let Some((_, version)) = versions.into_iter().next() {
cache.resolve(&version_id, version);
}

Ok(cache)
}
})
.await?;
if let Some(version) = version {
versions.push(version);
}
}
Ok(mm_config::version_get::Response { versions })
}

Expand Down
Loading