Skip to content

Commit 553ba73

Browse files
ldanilekConvex, Inc.
authored and
Convex, Inc.
committed
ConfigModel::apply don't fetch existing source (#25780)
we can avoid fetching existing module source when applying a new config, since all we need are the paths. GitOrigin-RevId: 524ff3b1950b8ced14dd73f8e68e8e63609291d3
1 parent 0595553 commit 553ba73

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Diff for: crates/model/src/config/mod.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,21 @@ impl<'a, RT: Runtime> ConfigModel<'a, RT> {
195195
let mut added_modules = BTreeSet::new();
196196

197197
// Add new modules.
198-
let mut remaining_modules = ModuleModel::new(self.tx)
199-
.get_application_modules(ComponentId::Root)
200-
.await?;
198+
let mut remaining_modules: BTreeSet<_> = ModuleModel::new(self.tx)
199+
.get_application_metadata(ComponentId::Root)
200+
.await?
201+
.into_iter()
202+
.map(|module| CanonicalizedComponentModulePath {
203+
component: ComponentId::Root,
204+
module_path: module.into_value().path,
205+
})
206+
.collect();
201207
for module in modules {
202208
let path = CanonicalizedComponentModulePath {
203209
component: ComponentId::Root,
204210
module_path: module.path.canonicalize(),
205211
};
206-
if remaining_modules.remove(&path).is_none() {
212+
if !remaining_modules.remove(&path) {
207213
added_modules.insert(path.clone());
208214
}
209215
let analyze_result = if !path.module_path.is_deps() {
@@ -230,7 +236,7 @@ impl<'a, RT: Runtime> ConfigModel<'a, RT> {
230236
}
231237

232238
let mut removed_modules = BTreeSet::new();
233-
for (path, _) in remaining_modules {
239+
for path in remaining_modules {
234240
removed_modules.insert(path.clone());
235241
ModuleModel::new(self.tx).delete(path).await?;
236242
}

Diff for: crates/model/src/modules/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
191191
Ok(modules)
192192
}
193193

194+
pub async fn get_application_metadata(
195+
&mut self,
196+
component: ComponentId,
197+
) -> anyhow::Result<Vec<ParsedDocument<ModuleMetadata>>> {
198+
let modules = self
199+
.get_all_metadata(component)
200+
.await?
201+
.into_iter()
202+
.filter(|metadata| !metadata.path.is_system())
203+
.collect();
204+
Ok(modules)
205+
}
206+
194207
/// Returns all registered modules that aren't system modules.
195208
pub async fn get_application_modules(
196209
&mut self,

0 commit comments

Comments
 (0)