refactor: collapse feature flags to federation+nats
This commit is contained in:
@@ -4,17 +4,17 @@ version = "0.1.0"
|
||||
edition.workspace = true
|
||||
|
||||
[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"]
|
||||
federation = ["application/federation"]
|
||||
sqlite-federation = [
|
||||
"sqlite",
|
||||
"dep:sqlite-federation",
|
||||
default = ["federation"]
|
||||
federation = [
|
||||
"dep:activitypub",
|
||||
"federation",
|
||||
"composition/sqlite-federation",
|
||||
"dep:sqlite-federation",
|
||||
"application/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]
|
||||
domain = { workspace = true }
|
||||
@@ -39,11 +39,10 @@ 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 }
|
||||
|
||||
# Optional — federation
|
||||
activitypub = { workspace = true, optional = true }
|
||||
activitypub = { workspace = true, optional = true }
|
||||
sqlite-federation = { workspace = true, optional = true }
|
||||
|
||||
@@ -13,7 +13,6 @@ pub async fn create(
|
||||
EventBusBackend::Db => {
|
||||
tracing::info!("event bus: DB queue");
|
||||
match db_pool {
|
||||
#[cfg(feature = "sqlite")]
|
||||
DbPool::Sqlite(pool) => {
|
||||
Ok(sqlite_event_queue::SqliteEventQueue::create_channel(pool.clone()).await?)
|
||||
}
|
||||
|
||||
@@ -13,16 +13,13 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
use domain::ports::{EventHandler, MovieEnrichmentClient, PeriodicJob, PersonEnrichmentClient};
|
||||
|
||||
#[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();
|
||||
init_tracing();
|
||||
|
||||
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 app_config = AppConfig::from_env();
|
||||
let instance = domain::value_objects::InstanceIdentity::new(app_config.base_url.clone());
|
||||
|
||||
@@ -82,7 +79,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
// Wire federation repos early to get remote_watchlist_repo for AppContext.
|
||||
#[cfg(feature = "federation")]
|
||||
let fed_repos = match &db.db_pool {
|
||||
#[cfg(feature = "sqlite-federation")]
|
||||
composition::DbPool::Sqlite(pool) => {
|
||||
sqlite_federation::wire(pool.clone(), instance.clone())
|
||||
}
|
||||
@@ -301,14 +297,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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("worker=info,application=info,k_ap=info"))
|
||||
|
||||
Reference in New Issue
Block a user