MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / check_module_validity

Method check_module_validity

crates/core/src/host/host_controller.rs:358–380  ·  view source on GitHub ↗

Construct an in-memory instance of `database` running `program`, initialize it, then immediately destroy it. This is used during an initial, fresh publish operation in order to check the `program`'s validity as a module, since some validity checks we'd like to do (e.g. typechecking RLS filters) require a fully instantiated database. This is not necessary during hotswap publishes, as the automigr

(&self, database: Database, program: Program)

Source from the content-addressed store, hash-verified

356 /// This is not necessary during hotswap publishes,
357 /// as the automigration planner and executor accomplish the same validity checks.
358 pub async fn check_module_validity(&self, database: Database, program: Program) -> anyhow::Result<Arc<ModuleInfo>> {
359 let (program, launched) = Host::try_init_in_memory_to_check(
360 &self.runtimes,
361 self.page_pool.clone(),
362 database,
363 program,
364 // This takes a db core to check validity, and we will later take
365 // another core to actually run the module. Due to the round-robin
366 // algorithm that JobCores uses, that will likely just be the same
367 // core - there's not a concern that we'll only end up using 1/2
368 // of the actual cores.
369 self.db_cores.take(),
370 self.bsatn_rlb_pool.clone(),
371 )
372 .await?;
373
374 let call_result = launched.module_host.init_database(program).await?;
375 if let Some(call_result) = call_result {
376 Result::from(call_result)?;
377 }
378
379 Ok(launched.module_host.info)
380 }
381
382 /// Update the [`ModuleHost`] identified by `replica_id` to the given
383 /// program.

Callers 2

publish_databaseMethod · 0.80
reset_databaseMethod · 0.80

Calls 4

OkFunction · 0.50
cloneMethod · 0.45
takeMethod · 0.45
init_databaseMethod · 0.45

Tested by

no test coverage detected