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

Method persistence

crates/engine/src/persistence.rs:225–258  ·  view source on GitHub ↗
(&self, database: &Database, replica_id: u64)

Source from the content-addressed store, hash-verified

223#[async_trait]
224impl PersistenceProvider for LocalPersistenceProvider {
225 async fn persistence(&self, database: &Database, replica_id: u64) -> anyhow::Result<Persistence> {
226 let database_identity = database.database_identity;
227 let replica_dir = self.data_dir.replica(replica_id);
228 let snapshot_dir = replica_dir.snapshots();
229 let runtime = Handle::tokio_current();
230
231 let snapshot_worker = asyncify(&runtime, move || {
232 relational_db::open_snapshot_repo(snapshot_dir, database_identity, replica_id)
233 })
234 .await
235 .map(|repo| SnapshotWorker::new(repo, snapshot::Compression::Enabled, runtime.clone()))?;
236 let (durability, disk_size) = relational_db::local_durability_with_options(
237 replica_dir,
238 runtime.clone(),
239 Some(&snapshot_worker),
240 self.durability.into_options(),
241 )
242 .await?;
243
244 runtime.spawn(relational_db::snapshot_watching_commitlog_compressor(
245 snapshot_worker.subscribe(),
246 None,
247 None,
248 durability.clone(),
249 runtime.clone(),
250 ));
251
252 Ok(Persistence {
253 durability,
254 disk_size,
255 snapshots: Some(snapshot_worker),
256 runtime,
257 })
258 }
259}

Callers 1

try_initMethod · 0.80

Calls 13

open_snapshot_repoFunction · 0.85
replicaMethod · 0.80
snapshotsMethod · 0.80
into_optionsMethod · 0.80
asyncifyFunction · 0.70
newFunction · 0.50
OkFunction · 0.50
mapMethod · 0.45
cloneMethod · 0.45
spawnMethod · 0.45

Tested by

no test coverage detected