(&self, database: &Database, replica_id: u64)
| 223 | #[async_trait] |
| 224 | impl 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 | } |
no test coverage detected