PostgreSQL operations for Ironflow workflows, powered by [sqlx].
This crate provides PostgreSQL operations as Ironflow
Operation implementations. Each
operation wraps a sqlx query, using a shared PgPool
for connection management.
Architecture
- [
PostgresClient] is the central handle, wrapping a connection pool - Each operation is a standalone struct implementing
Operation - All operations return
kind() == "postgres" - Queries use
sqlx::query()(runtime) because workflows define their SQL at execution time
Quick start
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,
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 |