Skip to main content

Crate ironflow_ops_postgres

Crate ironflow_ops_postgres 

Source
Expand description

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;

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?;

§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:

ModuleOperations
queryQueryRows, QueryOne, QueryScalar
executeExecute, ExecuteBatch, Transaction
schemaListDatabases, ListSchemas, ListTables, ListColumns, ListIndexes, ListConstraints, TableExists
adminHealthCheck, DatabaseSize, TableSize, ActiveConnections, RunningQueries, CancelQuery, TerminateBackend
maintenanceVacuum, Analyze, Reindex

Re-exports§

pub use sqlx;

Modules§

admin
Administration operations: health checks, size queries, connection monitoring, and query management.
execute
Mutating operations: INSERT, UPDATE, DELETE, batch execution, and transactions.
maintenance
Maintenance operations: VACUUM, ANALYZE, REINDEX.
query
Query operations: SELECT statements returning rows or scalar values.
schema
Schema introspection operations.

Structs§

PostgresClient
A PostgreSQL client wrapping a PgPool.