refactor: collapse feature flags to federation+nats

This commit is contained in:
2026-10-25 20:37:37 +01:00
parent 933400e1c2
commit 1b7384386a
17 changed files with 54 additions and 97 deletions

View File

@@ -5,10 +5,8 @@ edition.workspace = true
[features]
default = []
sqlite = ["dep:sqlite", "dep:sqlite-event-queue", "dep:sqlite-search", "dep:sqlite-social", "infra-wiring/sqlite"]
nats = ["dep:nats", "infra-wiring/nats"]
federation = ["application/federation"]
sqlite-federation = ["sqlite", "dep:sqlite-federation", "dep:activitypub", "federation"]
federation = ["application/federation", "dep:sqlite-federation", "dep:activitypub"]
[dependencies]
domain = { workspace = true }
@@ -21,11 +19,12 @@ object-storage = { workspace = true }
jellyfin = { workspace = true }
plex = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
sqlite = { workspace = true, optional = true }
sqlite-event-queue = { workspace = true, optional = true }
sqlite-search = { workspace = true, optional = true }
sqlite-social = { workspace = true, optional = true }
sqlite = { workspace = true }
sqlite-event-queue = { workspace = true }
sqlite-search = { workspace = true }
sqlite-social = { workspace = true }
nats = { workspace = true, optional = true }
activitypub = { workspace = true, optional = true }
sqlite-federation = { workspace = true, optional = true }

View File

@@ -123,9 +123,14 @@ pub fn build_profile_fields_repo(
pool: &DbPool,
) -> anyhow::Result<Arc<dyn UserProfileFieldsRepository>> {
match pool {
#[cfg(feature = "sqlite")]
DbPool::Sqlite(pool) => Ok(sqlite::create_profile_fields_repo(pool.clone())),
#[cfg(not(feature = "sqlite"))]
_ => anyhow::bail!("no profile fields repo for this backend"),
}
}
pub fn warn_if_database_backend_set() {
if let Ok(v) = std::env::var("DATABASE_BACKEND")
&& v != "sqlite"
{
tracing::warn!("DATABASE_BACKEND is ignored; SQLite is the only backend");
}
}

View File

@@ -265,11 +265,7 @@ fn test_repositories() -> Repositories {
}
/// A lazily-connected in-memory sqlite pool — never actually opened in this test,
/// just a value to satisfy `DatabaseOutput::db_pool`. Requires the `sqlite` feature,
/// which `cargo test --workspace` enables transitively (presentation/worker both
/// default to it), matching how `DbPool::Sqlite` is only constructible under that
/// feature everywhere else in the workspace.
#[cfg(feature = "sqlite")]
/// just a value to satisfy `DatabaseOutput::db_pool`.
fn test_db_pool() -> infra_wiring::DbPool {
let pool = sqlx::sqlite::SqlitePoolOptions::new()
.connect_lazy("sqlite::memory:")
@@ -277,14 +273,6 @@ fn test_db_pool() -> infra_wiring::DbPool {
infra_wiring::DbPool::Sqlite(pool)
}
#[cfg(not(feature = "sqlite"))]
fn test_db_pool() -> infra_wiring::DbPool {
unreachable!(
"worker_deps_wiring needs the sqlite feature; cargo test --workspace enables it \
transitively via presentation/worker's default features"
)
}
fn test_database_output() -> DatabaseOutput {
let movies = InMemoryMovieRepository::new();
let watch_events = InMemoryWatchEventRepository::new();