noetl_server/lib.rs
1//! NoETL Control Plane Library
2//!
3//! This crate provides the control plane server for NoETL, handling:
4//!
5//! - **Workflow Orchestration**: Execute playbooks and manage workflow state
6//! - **Catalog Management**: Register and retrieve playbooks, tools, and resources
7//! - **Credential Management**: Securely store and retrieve encrypted credentials
8//! - **Event Processing**: Handle worker events and drive workflow execution
9//! - **Execution Management**: Track and manage playbook executions
10//!
11//! ## Architecture
12//!
13//! The control plane follows an event-sourcing architecture where all state
14//! is derived from events stored in PostgreSQL. NATS JetStream is used for
15//! command notifications to workers.
16//!
17//! ## Modules
18//!
19//! - [`config`]: Configuration loading from environment variables
20//! - [`db`]: Database connectivity and models
21//! - [`error`]: Custom error types with Axum integration
22//! - [`handlers`]: HTTP route handlers
23//! - [`state`]: Shared application state
24//!
25//! ## Example
26//!
27//! ```ignore
28//! use noetl_control_plane::{
29//! config::{AppConfig, DatabaseConfig},
30//! db::create_pool,
31//! state::AppState,
32//! };
33//!
34//! #[tokio::main]
35//! async fn main() -> anyhow::Result<()> {
36//! let app_config = AppConfig::from_env()?;
37//! let db_config = DatabaseConfig::from_env()?;
38//! let db_pool = create_pool(&db_config).await?;
39//! // Single-pool fallback shim — production main.rs builds
40//! // the DbPoolMap from ShardingConfig::from_env() for the
41//! // sharded path; test / example code uses new_legacy.
42//! let state = AppState::new_legacy(db_pool, app_config, None);
43//! // ... build and run server
44//! Ok(())
45//! }
46//! ```
47
48pub mod config;
49pub mod crypto;
50pub mod db;
51pub mod engine;
52pub mod error;
53pub mod handlers;
54pub mod metrics;
55pub mod nats;
56pub mod playbook;
57pub mod result_ext;
58pub mod sanitize;
59pub mod secrets;
60pub mod services;
61pub mod sharding;
62pub mod tls;
63pub mod snowflake;
64pub mod state;
65pub mod template;
66
67pub use error::{AppError, AppResult};
68pub use result_ext::ResultExt;