refactor: drop postgres leftovers, narrow bootstrap api
This commit is contained in:
@@ -2,16 +2,11 @@ use std::sync::Arc;
|
||||
|
||||
use anyhow::Context;
|
||||
use domain::ports::{
|
||||
AuthService, ImageRefCommand, ImageRefQuery, LocalApContentQuery, MetadataClient,
|
||||
MovieDeduplicator, ObjectStorage, PasswordHasher, PosterFetcherClient,
|
||||
RefreshSessionRepository, UserProfileFieldsRepository, WatchEventCommand, WatchEventQuery,
|
||||
WebhookTokenRepository,
|
||||
AuthService, ImageRefCommand, ImageRefQuery, MetadataClient, MovieDeduplicator, ObjectStorage,
|
||||
PasswordHasher, PosterFetcherClient, RefreshSessionRepository, UserProfileFieldsRepository,
|
||||
WatchEventCommand, WatchEventQuery, WebhookTokenRepository,
|
||||
};
|
||||
|
||||
pub enum DbPool {
|
||||
Sqlite(sqlx::SqlitePool),
|
||||
}
|
||||
|
||||
pub struct DatabaseOutput {
|
||||
pub movie_command: Arc<dyn domain::ports::MovieCommand>,
|
||||
pub movie_query: Arc<dyn domain::ports::MovieQuery>,
|
||||
@@ -31,13 +26,15 @@ pub struct DatabaseOutput {
|
||||
pub search_port: Arc<dyn domain::ports::SearchPort>,
|
||||
pub search_command: Arc<dyn domain::ports::SearchCommand>,
|
||||
pub profile_fields: Arc<dyn UserProfileFieldsRepository>,
|
||||
pub ap_content: Arc<dyn LocalApContentQuery>,
|
||||
#[cfg(feature = "federation")]
|
||||
pub ap_content: Arc<dyn domain::ports::LocalApContentQuery>,
|
||||
pub wrapup_stats: Arc<dyn domain::ports::WrapUpStatsQuery>,
|
||||
pub wrapup_repo: Arc<dyn domain::ports::WrapUpRepository>,
|
||||
pub insights: Arc<dyn domain::ports::InsightsQuery>,
|
||||
pub goal_command: Arc<dyn domain::ports::GoalCommand>,
|
||||
pub goal_query: Arc<dyn domain::ports::GoalQuery>,
|
||||
pub user_settings: Arc<dyn domain::ports::UserSettingsRepository>,
|
||||
#[cfg(feature = "federation")]
|
||||
pub federation_settings: std::sync::Arc<dyn domain::ports::UserFederationSettingsQuery>,
|
||||
pub remote_goal: Arc<dyn domain::ports::RemoteGoalRepository>,
|
||||
pub refresh_session: Arc<dyn RefreshSessionRepository>,
|
||||
@@ -46,7 +43,7 @@ pub struct DatabaseOutput {
|
||||
pub image_ref_query: Arc<dyn ImageRefQuery>,
|
||||
pub follow_command: Arc<dyn domain::ports::FollowCommand>,
|
||||
pub follow_query: Arc<dyn domain::ports::FollowQuery>,
|
||||
pub db_pool: DbPool,
|
||||
pub db_pool: sqlx::SqlitePool,
|
||||
}
|
||||
|
||||
pub async fn build_database_adapters(
|
||||
@@ -105,6 +102,7 @@ fn assemble(
|
||||
search_port: sp,
|
||||
search_command: sc,
|
||||
profile_fields: pf,
|
||||
#[cfg(feature = "federation")]
|
||||
ap_content: w.ap_content,
|
||||
wrapup_stats: w.wrapup_stats,
|
||||
wrapup_repo: w.wrapup_repo,
|
||||
@@ -112,6 +110,7 @@ fn assemble(
|
||||
goal_command: w.goal_command,
|
||||
goal_query: w.goal_query,
|
||||
user_settings: w.user_settings,
|
||||
#[cfg(feature = "federation")]
|
||||
federation_settings: w.federation_settings,
|
||||
remote_goal: w.remote_goal,
|
||||
refresh_session: Arc::new(sqlite::SqliteRefreshSessionAdapter::new(w.pool.clone())) as _,
|
||||
@@ -120,7 +119,7 @@ fn assemble(
|
||||
image_ref_query,
|
||||
follow_command: Arc::clone(&social) as _,
|
||||
follow_query: social as _,
|
||||
db_pool: DbPool::Sqlite(w.pool),
|
||||
db_pool: w.pool,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -148,14 +147,6 @@ pub fn build_object_storage(
|
||||
object_storage::create(config)
|
||||
}
|
||||
|
||||
pub fn build_profile_fields_repo(
|
||||
pool: &DbPool,
|
||||
) -> anyhow::Result<Arc<dyn UserProfileFieldsRepository>> {
|
||||
match pool {
|
||||
DbPool::Sqlite(pool) => Ok(sqlite::create_profile_fields_repo(pool.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn warn_if_database_backend_set() {
|
||||
if let Ok(v) = std::env::var("DATABASE_BACKEND")
|
||||
&& v != "sqlite"
|
||||
|
||||
Reference in New Issue
Block a user