refactor: drop postgres backend
This commit is contained in:
@@ -6,7 +6,6 @@ edition.workspace = true
|
||||
[features]
|
||||
default = ["sqlite", "sqlite-federation"]
|
||||
sqlite = ["dep:sqlite", "dep:sqlite-event-queue", "dep:sqlite-search", "infra-wiring/sqlite", "composition/sqlite"]
|
||||
postgres = ["dep:postgres", "dep:postgres-event-queue", "dep:postgres-search", "infra-wiring/postgres", "composition/postgres"]
|
||||
nats = ["dep:nats", "infra-wiring/nats", "composition/nats"]
|
||||
federation = ["application/federation"]
|
||||
sqlite-federation = [
|
||||
@@ -16,13 +15,6 @@ sqlite-federation = [
|
||||
"federation",
|
||||
"composition/sqlite-federation",
|
||||
]
|
||||
postgres-federation = [
|
||||
"postgres",
|
||||
"dep:postgres-federation",
|
||||
"dep:activitypub",
|
||||
"federation",
|
||||
"composition/postgres-federation",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
domain = { workspace = true }
|
||||
@@ -49,13 +41,9 @@ async-trait = { workspace = true }
|
||||
|
||||
# Optional — database backends
|
||||
sqlite = { workspace = true, optional = true }
|
||||
postgres = { workspace = true, optional = true }
|
||||
sqlite-event-queue = { workspace = true, optional = true }
|
||||
postgres-event-queue = { workspace = true, optional = true }
|
||||
sqlite-search = { workspace = true, optional = true }
|
||||
postgres-search = { workspace = true, optional = true }
|
||||
|
||||
# Optional — federation
|
||||
activitypub = { workspace = true, optional = true }
|
||||
sqlite-federation = { workspace = true, optional = true }
|
||||
postgres-federation = { workspace = true, optional = true }
|
||||
|
||||
@@ -13,10 +13,6 @@ pub async fn create(
|
||||
EventBusBackend::Db => {
|
||||
tracing::info!("event bus: DB queue");
|
||||
match db_pool {
|
||||
#[cfg(feature = "postgres")]
|
||||
DbPool::Postgres(pool) => Ok(
|
||||
postgres_event_queue::PostgresEventQueue::create_channel(pool.clone()).await?,
|
||||
),
|
||||
#[cfg(feature = "sqlite")]
|
||||
DbPool::Sqlite(pool) => {
|
||||
Ok(sqlite_event_queue::SqliteEventQueue::create_channel(pool.clone()).await?)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
mod event_bus;
|
||||
#[cfg(feature = "federation")]
|
||||
mod follow_backfill_handler;
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -12,10 +13,8 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
use domain::ports::{EventHandler, MovieEnrichmentClient, PeriodicJob, PersonEnrichmentClient};
|
||||
|
||||
#[cfg(not(any(feature = "sqlite", feature = "postgres")))]
|
||||
compile_error!(
|
||||
"At least one database backend must be enabled. Use --features sqlite or --features postgres"
|
||||
);
|
||||
#[cfg(not(feature = "sqlite"))]
|
||||
compile_error!("The sqlite feature must be enabled. Use --features sqlite");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
@@ -23,7 +22,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
init_tracing();
|
||||
|
||||
let database_url = std::env::var("DATABASE_URL").context("DATABASE_URL must be set")?;
|
||||
let backend = std::env::var("DATABASE_BACKEND").unwrap_or_else(|_| "sqlite".to_string());
|
||||
warn_if_database_backend_set();
|
||||
let app_config = AppConfig::from_env();
|
||||
let instance = domain::value_objects::InstanceIdentity::new(app_config.base_url.clone());
|
||||
|
||||
@@ -47,8 +46,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
.clone()
|
||||
.map(|c| c as Arc<dyn PersonEnrichmentClient>);
|
||||
|
||||
let db =
|
||||
composition::factory::build_database_adapters(&backend, &database_url, &instance).await?;
|
||||
let db = composition::factory::build_database_adapters(&database_url, &instance).await?;
|
||||
let (event_publisher_arc, consumer_arc) = event_bus::create(&db.db_pool).await?;
|
||||
|
||||
let worker_services = application::WorkerServices {
|
||||
@@ -88,10 +86,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
composition::DbPool::Sqlite(pool) => {
|
||||
sqlite_federation::wire(pool.clone(), instance.clone())
|
||||
}
|
||||
#[cfg(feature = "postgres-federation")]
|
||||
composition::DbPool::Postgres(pool) => {
|
||||
postgres_federation::wire(pool.clone(), instance.clone())
|
||||
}
|
||||
};
|
||||
|
||||
let movie_command = db.movie_command;
|
||||
@@ -103,6 +97,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
let person_query = db.person_query;
|
||||
let search_command = db.search_command;
|
||||
let wrapup_repo = db.wrapup_repo;
|
||||
#[cfg(feature = "federation")]
|
||||
let remote_goal = db.remote_goal;
|
||||
let refresh_session = db.refresh_session;
|
||||
|
||||
@@ -306,6 +301,14 @@ 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