ironflow_ops_postgres/lib.rs
1//! PostgreSQL operations for Ironflow workflows, powered by [`sqlx`].
2//!
3//! This crate provides PostgreSQL operations as Ironflow
4//! [`Operation`](ironflow_core::operation::Operation) implementations. Each
5//! operation wraps a `sqlx` query, using a shared [`PgPool`](sqlx::PgPool)
6//! for connection management.
7//!
8//! # Architecture
9//!
10//! - [`PostgresClient`] is the central handle, wrapping a connection pool
11//! - Each operation is a standalone struct implementing [`Operation`](ironflow_core::operation::Operation)
12//! - All operations return `kind() == "postgres"`
13//! - Queries use `sqlx::query()` (runtime) because workflows define their
14//! SQL at execution time
15//!
16//! # Quick start
17//!
18//! ```no_run
19//! use ironflow_ops_postgres::PostgresClient;
20//! use ironflow_ops_postgres::admin::health::HealthCheck;
21//! use ironflow_ops_postgres::query::QueryRows;
22//! use ironflow_core::operation::{Operation, OperationContext, NoopSecretResolver};
23//! use std::sync::Arc;
24//!
25//! # async fn example() -> Result<(), ironflow_core::error::OperationError> {
26//! let client = PostgresClient::connect("postgres://localhost/mydb").await?;
27//! let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
28//!
29//! // Health check
30//! let health = HealthCheck::new(client.pool().clone());
31//! health.execute(&ctx).await?;
32//!
33//! // Query rows
34//! let query = QueryRows::new(
35//! client.pool().clone(),
36//! "SELECT id, name FROM users WHERE active = $1",
37//! vec![serde_json::json!(true)],
38//! );
39//! let result = query.execute(&ctx).await?;
40//! # Ok(())
41//! # }
42//! ```
43//!
44//! # Tracked operations
45//!
46//! Every operation implements [`Operation`](ironflow_core::operation::Operation),
47//! so it can be passed to `WorkflowContext::operation()` for step lifecycle
48//! tracking (step record, status transitions, duration, output persistence).
49//!
50//! # Modules
51//!
52//! Operations are organized by domain:
53//!
54//! | Module | Operations |
55//! |--------|-----------|
56//! | [`query`] | QueryRows, QueryOne, QueryScalar |
57//! | [`execute`] | Execute, ExecuteBatch, Transaction |
58//! | [`schema`] | ListDatabases, ListSchemas, ListTables, ListColumns, ListIndexes, ListConstraints, TableExists |
59//! | [`admin`] | HealthCheck, DatabaseSize, TableSize, ActiveConnections, RunningQueries, CancelQuery, TerminateBackend |
60//! | [`maintenance`] | Vacuum, Analyze, Reindex |
61
62pub mod admin;
63mod client;
64pub mod execute;
65mod helpers;
66pub mod maintenance;
67pub mod query;
68pub mod schema;
69
70pub use client::PostgresClient;
71pub use sqlx;