Skip to content

Commit 59e77cf

Browse files
committed
make compatible to private
1 parent 57efabd commit 59e77cf

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

crates/core/src/host/host_controller.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,12 @@ impl Host {
904904
db::Storage::Disk => {
905905
// Replay from the local state.
906906
let history = relational_db::local_history(&replica_dir, &runtime).await?;
907-
let persistence = persistence.persistence(database.database_identity, replica_id).await?;
907+
let persistence_db = db::persistence::Database {
908+
id: database.id,
909+
database_identity: database.database_identity,
910+
owner_identity: database.owner_identity,
911+
};
912+
let persistence = persistence.persistence(&persistence_db, replica_id).await?;
908913
// Loading a database from persistent storage involves heavy
909914
// blocking I/O. `asyncify` to avoid blocking the async worker.
910915
let (db, clients) = asyncify({

crates/engine/src/db/persistence.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ pub type Durability = dyn spacetimedb_durability::Durability<TxData = Txdata>;
8585
/// configured or the database is in follower state.
8686
pub type DiskSizeFn = Arc<dyn Fn() -> io::Result<SizeOnDisk> + Send + Sync>;
8787

88+
#[derive(Clone, Copy, Debug)]
89+
pub struct Database {
90+
pub id: u64,
91+
pub database_identity: Identity,
92+
pub owner_identity: Identity,
93+
}
94+
8895
/// Persistence services for a database.
8996
pub struct Persistence {
9097
/// The [Durability] to use, for persisting transactions.
@@ -182,7 +189,7 @@ impl Persistence {
182189
/// This is an `async_trait` to allow it to be used as a trait object.
183190
#[async_trait]
184191
pub trait PersistenceProvider: Send + Sync {
185-
async fn persistence(&self, database_identity: Identity, replica_id: u64) -> anyhow::Result<Persistence>;
192+
async fn persistence(&self, database: &Database, replica_id: u64) -> anyhow::Result<Persistence>;
186193
}
187194

188195
/// The standard [PersistenceProvider] for non-replicated databases.
@@ -215,7 +222,8 @@ impl LocalPersistenceProvider {
215222

216223
#[async_trait]
217224
impl PersistenceProvider for LocalPersistenceProvider {
218-
async fn persistence(&self, database_identity: Identity, replica_id: u64) -> anyhow::Result<Persistence> {
225+
async fn persistence(&self, database: &Database, replica_id: u64) -> anyhow::Result<Persistence> {
226+
let database_identity = database.database_identity;
219227
let replica_dir = self.data_dir.replica(replica_id);
220228
let snapshot_dir = replica_dir.snapshots();
221229
let runtime = Handle::tokio_current();

0 commit comments

Comments
 (0)