Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ members = [
"crates/cache",
"crates/engine",
"crates/storage",
"crates/config",
"crates/storage-postgres",
"crates/auth",
"crates/server",
"crates/app",
"crates/bin",
]

Expand All @@ -25,9 +27,11 @@ extenddb-core = { path = "crates/core" }
extenddb-cache = { path = "crates/cache" }
extenddb-engine = { path = "crates/engine" }
extenddb-storage = { path = "crates/storage" }
extenddb-config = { path = "crates/config" }
extenddb-storage-postgres = { path = "crates/storage-postgres" }
extenddb-auth = { path = "crates/auth" }
extenddb-server = { path = "crates/server" }
extenddb-app = { path = "crates/app" }

# Serialization
serde = { version = "1", features = ["derive"] }
Expand All @@ -40,6 +44,7 @@ anyhow = "1"

# Async
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7" }
async-trait = "0.1"
futures = "0.3"

Expand All @@ -50,9 +55,6 @@ tower-http = { version = "0.6", features = ["compression-gzip", "cors", "set-hea
hyper = { version = "1" }
urlencoding = { version = "2.1" }

# Database plugin registry
inventory = "0.3"

# Caching
moka = { version = "0.12", features = ["future"] }

Expand Down
33 changes: 33 additions & 0 deletions crates/app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2026 ExtendDB contributors
# SPDX-License-Identifier: Apache-2.0
[package]
name = "extenddb-app"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[dependencies]
extenddb-auth = { workspace = true }
extenddb-cache = { workspace = true }
extenddb-core = { workspace = true }
extenddb-engine = { workspace = true }
extenddb-storage = { workspace = true }
extenddb-config = { workspace = true }
extenddb-server = { workspace = true }
tokio = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true }
daemonize = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sqlx = { workspace = true }
time = { workspace = true }
toml = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
base64 = { workspace = true }
libc = { workspace = true }
rcgen = { workspace = true }
rustls = { workspace = true }
rustls-pemfile = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::collections::HashSet;
use clap::Args;
use sqlx::postgres::PgPoolOptions;

use crate::config;
use extenddb_config as config;

#[derive(Args)]
pub struct CatalogCheckArgs {
Expand Down Expand Up @@ -47,7 +47,7 @@ pub async fn run(args: CatalogCheckArgs) -> anyhow::Result<()> {
let run_dir = config::expand_tilde(&app_config.server.run_dir);

// Refuse to run while server is up.
let pid_path = crate::serve_helpers::pid_file_path(&run_dir, port);
let pid_path = extenddb_config::pid_file_path(&run_dir, port);
if let Ok(contents) = std::fs::read_to_string(&pid_path)
&& let Ok(pid) = contents.trim().parse::<i32>()
&& crate::util::is_process_alive(pid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use clap::Args;

use crate::config;
use extenddb_config as config;

#[derive(Args)]
#[allow(clippy::doc_markdown)] // Clap help text, not rustdoc
Expand Down Expand Up @@ -49,7 +49,7 @@ pub async fn run(args: DestroyArgs) -> anyhow::Result<()> {

// Create bootstrap store for catalog queries and database teardown.
let bootstrap =
extenddb_storage::bootstrapper::create_bootstrapper(backend, &args.config, &cli_args).await;
extenddb_storage::bootstrapper::create_bootstrapper(&args.config, &cli_args).await;

let mut data_db = String::new();

Expand Down Expand Up @@ -96,16 +96,15 @@ pub async fn run(args: DestroyArgs) -> anyhow::Result<()> {
// connects to the `postgres` database, so we can reuse it.
if !data_db.is_empty() {
// Defense-in-depth: validate even though this came from the catalog.
config::validate_identifier(backend, &data_db, "data database name")?;
config::validate_identifier(&data_db, "data database name")?;
}

// Reconnect as admin for DDL operations (the catalog pool must be dropped
// before we can DROP DATABASE).
drop(bootstrap);
let bootstrap =
extenddb_storage::bootstrapper::create_bootstrapper(backend, &args.config, &cli_args)
.await
.map_err(|e| anyhow::anyhow!("Cannot connect as admin: {e:?}"))?;
let bootstrap = extenddb_storage::bootstrapper::create_bootstrapper(&args.config, &cli_args)
.await
.map_err(|e| anyhow::anyhow!("Cannot connect as admin: {e:?}"))?;

bootstrap
.drop_databases(&data_db)
Expand Down
9 changes: 4 additions & 5 deletions crates/bin/src/cmd_init.rs → crates/app/src/cmd_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use std::path::Path;

use clap::Args;

use crate::config;
use crate::init_helpers::{generate_config, generate_tls_cert_if_needed};
use extenddb_config as config;

#[derive(Args)]
#[allow(clippy::doc_markdown)] // Clap help text, not rustdoc
Expand Down Expand Up @@ -140,10 +140,9 @@ pub async fn run(args: InitArgs) -> anyhow::Result<u8> {
let cli_args: Vec<String> = std::env::args().collect();

// Create bootstrapper via registry (no hardcoded match!)
let bootstrapper =
extenddb_storage::bootstrapper::create_bootstrapper(&backend, &args.config, &cli_args)
.await
.map_err(|e| anyhow::anyhow!("{e:?}"))?;
let bootstrapper = extenddb_storage::bootstrapper::create_bootstrapper(&args.config, &cli_args)
.await
.map_err(|e| anyhow::anyhow!("{e:?}"))?;

// Ensure application user exists.
bootstrapper
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use clap::Args;

use crate::config;
use extenddb_config as config;

#[derive(Args)]
pub struct MigrateArgs {
Expand Down Expand Up @@ -36,8 +36,10 @@ pub async fn run(args: MigrateArgs) -> anyhow::Result<()> {
args.config,
);
}
let app_config = config::load(&args.config)?;
let backend = &app_config.storage.backend;
// Load the config for validation only: migrate drives the bootstrapper from
// the config path directly, but a malformed config should fail here rather
// than midway through a migration.
config::load(&args.config)?;

println!("=== extenddb migrate ===");
println!("Config: {}", args.config);
Expand All @@ -47,10 +49,9 @@ pub async fn run(args: MigrateArgs) -> anyhow::Result<()> {
let cli_args: Vec<String> = std::env::args().collect();

// Create bootstrapper via registry
let bootstrap =
extenddb_storage::bootstrapper::create_bootstrapper(backend, &args.config, &cli_args)
.await
.map_err(|e| anyhow::anyhow!("{e:?}"))?;
let bootstrap = extenddb_storage::bootstrapper::create_bootstrapper(&args.config, &cli_args)
.await
.map_err(|e| anyhow::anyhow!("{e:?}"))?;

// Show current catalog version.
println!("--- Checking current catalog version...");
Expand Down
Loading
Loading