-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: run data migrations on daemon start with cli flag
- Loading branch information
Showing
4 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,48 @@ | ||
mod error; | ||
mod event; | ||
mod interest; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
use std::sync::Arc; | ||
|
||
use ceramic_store::{DataMigrator, SqlitePool}; | ||
pub use error::Error; | ||
pub use event::CeramicEventService; | ||
pub use interest::CeramicInterestService; | ||
|
||
pub(crate) type Result<T> = std::result::Result<T, Error>; | ||
|
||
/// The ceramic service holds the logic needed by the other components (e.g. api, recon) to access the store and process events | ||
/// in a way that makes sense to the ceramic protocol, and not just as raw bytes. | ||
#[derive(Debug)] | ||
pub struct CeramicService { | ||
pub(crate) interest: Arc<CeramicInterestService>, | ||
pub(crate) event: Arc<CeramicEventService>, | ||
} | ||
|
||
impl CeramicService { | ||
/// Create a new CeramicService | ||
pub async fn try_new(pool: SqlitePool) -> Result<Self> { | ||
let interest = Arc::new(CeramicInterestService::new(pool.clone())); | ||
let event = Arc::new(CeramicEventService::new(pool).await?); | ||
Ok(Self { interest, event }) | ||
} | ||
|
||
/// Get the interest service | ||
pub fn interest_service(&self) -> &Arc<CeramicInterestService> { | ||
&self.interest | ||
} | ||
|
||
/// Get the event service | ||
pub fn event_service(&self) -> &Arc<CeramicEventService> { | ||
&self.event | ||
} | ||
|
||
/// Get the data migrator | ||
pub async fn data_migrator(&self) -> Result<DataMigrator> { | ||
let m = DataMigrator::try_new(self.event.pool.clone()).await?; | ||
Ok(m) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters