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
44 changes: 14 additions & 30 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ members = [
"crates/controller-admin-providers",
"crates/controller-admin-system",
"crates/controller-admin-tables",
"crates/services/admin-api",
"crates/services/admin-api/gen",
"crates/services/controller",
"crates/services/controller/gen",
"crates/services/server",
"crates/services/metadata-db-postgres",
"crates/services/worker",
Expand Down
1 change: 0 additions & 1 deletion crates/core/monitoring/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub fn init_with_telemetry(url: &str, trace_ratio: f64) -> telemetry::traces::Re

/// List of crates in the workspace.
const AMP_CRATES: &[&str] = &[
"admin_api",
"admin_client",
"amp_client",
"amp_config",
Expand Down
25 changes: 0 additions & 25 deletions crates/services/admin-api/Cargo.toml

This file was deleted.

59 changes: 0 additions & 59 deletions crates/services/admin-api/README.md

This file was deleted.

10 changes: 9 additions & 1 deletion crates/services/controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ edition = "2024"
version.workspace = true
license-file.workspace = true

[features]
utoipa = ["dep:utoipa", "amp-controller-admin-datasets/utoipa", "amp-controller-admin-jobs/utoipa", "amp-controller-admin-providers/utoipa", "amp-controller-admin-system/utoipa", "amp-controller-admin-tables/utoipa"]

[dependencies]
admin-api = { path = "../admin-api" }
amp-controller-admin-datasets = { path = "../../controller-admin-datasets" }
amp-controller-admin-jobs = { path = "../../controller-admin-jobs" }
amp-controller-admin-providers = { path = "../../controller-admin-providers" }
amp-controller-admin-system = { path = "../../controller-admin-system" }
amp-controller-admin-tables = { path = "../../controller-admin-tables" }
amp-data-store = { path = "../../core/data-store" }
amp-datasets-registry = { version = "0.1.0", path = "../../core/datasets-registry" }
amp-providers-registry = { version = "0.1.0", path = "../../core/providers-registry" }
Expand All @@ -19,8 +25,10 @@ metadata-db = { version = "0.1.0", path = "../../core/metadata-db" }
monitoring = { path = "../../core/monitoring" }
opentelemetry-instrumentation-tower = { version = "0.17.0", features = ["axum"] }
rand.workspace = true
serde.workspace = true
thiserror.workspace = true
tokio.workspace = true
tower-http = { workspace = true, features = ["cors"] }
tracing.workspace = true
utoipa = { version = "5.4.0", features = ["axum_extras"], optional = true }
worker = { version = "0.1.0", path = "../worker" }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "admin-api-gen"
name = "amp-controller-admin-api-gen"
edition.workspace = true
version.workspace = true
license-file.workspace = true
Expand All @@ -8,7 +8,7 @@ publish = false
# Schema generation dependencies (see README.md "OpenAPI Schema Generation" section)
# These dependencies are only included when the gen_openapi_spec cfg flag is enabled
[target.'cfg(gen_openapi_spec)'.build-dependencies]
admin-api = { path = "..", features = ["utoipa"] }
controller = { path = "..", features = ["utoipa"] }
serde_json.workspace = true

[lints.rust]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
);

let out_dir = std::env::var("OUT_DIR")?;
let spec = admin_api::generate_openapi_spec();
let spec = controller::generate_openapi_spec();
let spec_json = serde_json::to_string_pretty(&spec)?;
let spec_path = format!("{out_dir}/openapi.spec.json");
std::fs::write(&spec_path, spec_json)?;
Expand Down
9 changes: 7 additions & 2 deletions crates/services/controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
//!
//! The controller service provides the admin API for managing Amp operations.

pub mod build_info;
pub mod ctx;
pub mod handlers;
mod router;
mod scheduler;
pub mod service;

// Re-export build_info to avoid code duplication
pub use admin_api::build_info;
#[cfg(feature = "utoipa")]
pub use router::generate_openapi_spec;
pub(crate) use router::router;
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
//! Amp Admin API
//! Amp Admin API router and OpenAPI specification
use std::sync::Arc;

use axum::Router;

pub mod build_info;
pub mod ctx;
pub mod handlers;

use ctx::Ctx;

use crate::ctx::{RevisionGuardImpl, WorkerServiceImpl};
use crate::ctx::{Ctx, RevisionGuardImpl, WorkerServiceImpl};

/// Create the admin API router with all routes registered
///
/// Returns a router configured with all admin API endpoints.
pub fn router(ctx: Ctx) -> Router<()> {
pub(crate) fn router(ctx: Ctx) -> Router<()> {
let tables_ctx = amp_controller_admin_tables::ctx::Ctx {
metadata_db: ctx.metadata_db.clone(),
datasets_registry: ctx.datasets_registry.clone(),
Expand Down Expand Up @@ -114,7 +108,7 @@ pub fn router(ctx: Ctx) -> Router<()> {
),
components(schemas(
// Common schemas
handlers::error::ErrorResponse,
crate::handlers::error::ErrorResponse,
// Manifest schemas
amp_controller_admin_datasets::manifests::handlers::list_all::ManifestsResponse,
amp_controller_admin_datasets::manifests::handlers::list_all::ManifestInfo,
Expand Down
5 changes: 2 additions & 3 deletions crates/services/controller/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{future::Future, net::SocketAddr, sync::Arc, time::Duration};

use admin_api::ctx::Ctx;
use amp_data_store::DataStore;
use amp_datasets_registry::DatasetsRegistry;
use amp_providers_registry::ProvidersRegistry;
Expand All @@ -17,7 +16,7 @@ use opentelemetry_instrumentation_tower::HTTPMetricsLayerBuilder;
use tokio::{net::TcpListener, time::MissedTickBehavior};
use tower_http::cors::CorsLayer;

use crate::{build_info::BuildInfo, scheduler::Scheduler};
use crate::{build_info::BuildInfo, ctx::Ctx, scheduler::Scheduler};

/// Reconciliation interval for failed job retries
///
Expand Down Expand Up @@ -61,7 +60,7 @@ pub async fn new(
// Create controller router with health check endpoint
let mut app = Router::new()
.route("/healthz", get(|| async { StatusCode::OK }))
.merge(admin_api::router(ctx));
.merge(crate::router(ctx));

// Add OpenTelemetry HTTP metrics middleware if meter is provided
if let Some(meter) = meter {
Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ gen:
echo " {{GEN_PROVIDER_SCHEMAS_OUTDIR}}/static.spec.json"

# Admin API (OpenAPI spec)
cp -f $(ls -t target/debug/build/admin-api-gen-*/out/openapi.spec.json | head -1) {{GEN_OPENAPI_SCHEMAS_OUTDIR}}/admin.spec.json
cp -f $(ls -t target/debug/build/amp-controller-admin-api-gen-*/out/openapi.spec.json | head -1) {{GEN_OPENAPI_SCHEMAS_OUTDIR}}/admin.spec.json
echo " {{GEN_OPENAPI_SCHEMAS_OUTDIR}}/admin.spec.json"

### ampd Config
Expand Down Expand Up @@ -410,9 +410,9 @@ gen-static-provider-schema DEST_DIR=GEN_PROVIDER_SCHEMAS_OUTDIR:
# Generate the admin API OpenAPI specification
[group: 'codegen']
gen-admin-api-openapi-spec DEST_DIR=GEN_OPENAPI_SCHEMAS_OUTDIR:
RUSTFLAGS="--cfg gen_openapi_spec" cargo check -p admin-api-gen
RUSTFLAGS="--cfg gen_openapi_spec" cargo check -p amp-controller-admin-api-gen
@mkdir -p {{DEST_DIR}}
@cp -f $(ls -t target/debug/build/admin-api-gen-*/out/openapi.spec.json | head -1) {{DEST_DIR}}/admin.spec.json
@cp -f $(ls -t target/debug/build/amp-controller-admin-api-gen-*/out/openapi.spec.json | head -1) {{DEST_DIR}}/admin.spec.json
@echo "Schema generated and copied to {{DEST_DIR}}/admin.spec.json"

### Worker
Expand Down
Loading