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