refactor: collapse feature flags to federation+nats
This commit is contained in:
@@ -6,19 +6,18 @@ description = "Self-hosted movie diary with REST API and ActivityPub federation"
|
||||
license = "MIT"
|
||||
|
||||
[features]
|
||||
default = ["sqlite", "sqlite-federation"]
|
||||
sqlite = ["dep:sqlite", "dep:sqlite-event-queue", "dep:sqlite-search", "infra-wiring/sqlite", "composition/sqlite"]
|
||||
nats = ["dep:nats", "infra-wiring/nats", "composition/nats"]
|
||||
# Meta-feature: true when any federation adapter is active — keeps all #[cfg(feature = "federation")] gates working
|
||||
federation = ["application/federation", "presentation/federation"]
|
||||
sqlite-federation = [
|
||||
"sqlite",
|
||||
"dep:sqlite-federation",
|
||||
"dep:sqlite-social",
|
||||
default = ["federation"]
|
||||
federation = [
|
||||
"dep:activitypub",
|
||||
"federation",
|
||||
"composition/sqlite-federation",
|
||||
"dep:sqlite-federation",
|
||||
"application/federation",
|
||||
"presentation/federation",
|
||||
"composition/federation",
|
||||
]
|
||||
nats = ["dep:nats", "infra-wiring/nats", "composition/nats"]
|
||||
# deprecated aliases kept so existing deploy commands keep working
|
||||
sqlite = []
|
||||
sqlite-federation = ["federation"]
|
||||
|
||||
[dependencies]
|
||||
axum = { workspace = true }
|
||||
@@ -44,15 +43,14 @@ sqlx = { workspace = true }
|
||||
infra-wiring = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
|
||||
# Optional — database backends
|
||||
sqlite = { workspace = true, optional = true }
|
||||
sqlite-event-queue = { workspace = true, optional = true }
|
||||
sqlite-search = { workspace = true, optional = true }
|
||||
sqlite = { workspace = true }
|
||||
sqlite-event-queue = { workspace = true }
|
||||
sqlite-search = { workspace = true }
|
||||
sqlite-social = { workspace = true }
|
||||
|
||||
# Optional — federation
|
||||
activitypub = { workspace = true, optional = true }
|
||||
activitypub = { workspace = true, optional = true }
|
||||
sqlite-federation = { workspace = true, optional = true }
|
||||
sqlite-social = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
bytes = { workspace = true }
|
||||
|
||||
@@ -16,9 +16,6 @@ use rss::RssAdapter;
|
||||
use domain::ports::{DiaryExporter, DocumentParser, EventPublisher};
|
||||
use infra_wiring::EventBusBackend;
|
||||
|
||||
#[cfg(not(feature = "sqlite"))]
|
||||
compile_error!("The sqlite feature must be enabled. Use --features sqlite");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
dotenvy::dotenv().ok();
|
||||
@@ -48,7 +45,7 @@ async fn wire_dependencies() -> anyhow::Result<(AppState, axum::Router)> {
|
||||
let app_config = AppConfig::from_env();
|
||||
let instance = domain::value_objects::InstanceIdentity::new(app_config.base_url.clone());
|
||||
let database_url = std::env::var("DATABASE_URL").context("DATABASE_URL must be set")?;
|
||||
warn_if_database_backend_set();
|
||||
composition::factory::warn_if_database_backend_set();
|
||||
|
||||
let (auth_service, password_hasher) = composition::factory::build_auth_adapters()?;
|
||||
let metadata_client = composition::factory::build_metadata_client()?;
|
||||
@@ -76,7 +73,6 @@ async fn wire_dependencies() -> anyhow::Result<(AppState, axum::Router)> {
|
||||
block_query_arc,
|
||||
) = {
|
||||
let fed_repos = match &db_pool {
|
||||
#[cfg(feature = "sqlite-federation")]
|
||||
composition::DbPool::Sqlite(pool) => {
|
||||
sqlite_federation::wire(pool.clone(), instance.clone())
|
||||
}
|
||||
@@ -214,7 +210,6 @@ async fn wire_dependencies() -> anyhow::Result<(AppState, axum::Router)> {
|
||||
#[cfg(feature = "federation")]
|
||||
federated_profile: Some({
|
||||
match &db_pool {
|
||||
#[cfg(feature = "sqlite-federation")]
|
||||
composition::DbPool::Sqlite(pool) => {
|
||||
sqlite_social::create_federated_profile_query(pool.clone(), instance.clone())
|
||||
}
|
||||
@@ -272,7 +267,6 @@ async fn create_event_publisher(
|
||||
EventBusBackend::Db => {
|
||||
tracing::info!("event bus: DB queue");
|
||||
Ok(match db_pool {
|
||||
#[cfg(feature = "sqlite")]
|
||||
composition::DbPool::Sqlite(pool) => {
|
||||
sqlite_event_queue::SqliteEventQueue::create_publisher(pool.clone()).await?
|
||||
}
|
||||
@@ -288,14 +282,6 @@ async fn create_event_publisher(
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
fn init_tracing() {
|
||||
tracing_subscriber::registry()
|
||||
.with(log_filter("server=debug,tower_http=debug"))
|
||||
|
||||
@@ -362,9 +362,7 @@ impl SearchCommand for PanicSearchCommand {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "federation")]
|
||||
struct PanicRemoteWatchlist;
|
||||
#[cfg(feature = "federation")]
|
||||
#[async_trait::async_trait]
|
||||
impl domain::ports::RemoteWatchlistRepository for PanicRemoteWatchlist {
|
||||
async fn save(&self, _: domain::models::RemoteWatchlistEntry) -> Result<(), DomainError> {
|
||||
|
||||
Reference in New Issue
Block a user