footing 0.6.5

Feature-gated foundations for Rust backend services
Documentation
//! SQLx PostgreSQL helpers with explicit configuration, diagnostics, and runtime boundaries.
//!
//! [`PostgresConnectionSettings`](crate::db::postgres::PostgresConnectionSettings) owns
//! connection identity and server-side session deadlines;
//! [`PostgresPoolSettings`](crate::db::postgres::PostgresPoolSettings) owns pool sizing
//! and connection recycling.
//! [`connect_options`](crate::db::postgres::connect_options) exposes SQLx options for further customization without
//! bypassing URL validation or the driver's parsing-log isolation.
//!
//! [`bootstrap_database`](crate::db::postgres::bootstrap_database) migrates on the same pool it returns. When migrations
//! need different credentials or statement deadlines, build their connection
//! settings independently and close the migration pool before serving requests:
//!
//! ```no_run
//! use std::time::Duration;
//! use footing::db::postgres::{PostgresConnectionSettings, PostgresPoolSettings,
//!     connect_pool, run_migrations};
//! use sqlx::{PgPool, migrate::Migrator};
//!
//! async fn start_database(
//!     migration_url: &str,
//!     runtime_url: &str,
//!     migrator: &Migrator,
//! ) -> Result<PgPool, Box<dyn std::error::Error>> {
//!     let migration = PostgresConnectionSettings::new(migration_url)
//!         .with_statement_timeout(Some(Duration::from_secs(60)))
//!         .build()?;
//!     let pool = connect_pool(
//!         &migration,
//!         PostgresPoolSettings::default().with_max_connections(1).build()?,
//!     ).await?;
//!     run_migrations(&pool, migrator).await?;
//!     pool.close().await;
//!
//!     let runtime = PostgresConnectionSettings::new(runtime_url)
//!         .with_statement_timeout(Some(Duration::from_secs(5)))
//!         .with_idle_in_transaction_session_timeout(Some(Duration::from_secs(30)))
//!         .build()?;
//!     Ok(connect_pool(&runtime, PostgresPoolSettings::default().build()?).await?)
//! }
//! ```

#[cfg(feature = "postgres-admin")]
#[cfg_attr(docsrs, doc(cfg(feature = "postgres-admin")))]
/// Explicitly gated destructive PostgreSQL administration operations.
pub mod admin;
mod config;
mod connection;
mod diagnostics;
mod identity;
mod runtime;

pub use config::{
    DEFAULT_POSTGRES_ADVISORY_LOCK_TIMEOUT, DEFAULT_POSTGRES_ENSURE_DATABASE_TIMEOUT,
    DEFAULT_POSTGRES_MIGRATION_TIMEOUT, PostgresBootstrapConfig, PostgresBootstrapSettings,
    PostgresPoolConfig, PostgresPoolSettings, PostgresStartupRetryConfig,
    PostgresStartupRetrySettings,
};
pub use connection::{PostgresConnectionConfig, PostgresConnectionSettings};
pub use diagnostics::{
    PostgresBootstrapError, PostgresDiagnostic, PostgresDiagnosticKind, PostgresOperation,
    PostgresPoolError, diagnose_migration_error, diagnose_migration_lock_timeout,
    diagnose_operation_timeout, diagnose_pool_error, diagnose_sqlx_error,
};
pub use identity::{
    advisory_lock_key, database_name, redact_database_url, schema_maintenance_advisory_lock_key,
};
pub use runtime::{
    PostgresHealth, PostgresHealthStatus, PostgresMigrationRunError, PostgresTransaction,
    acquire_advisory_transaction_lock, acquire_shared_advisory_transaction_lock,
    bootstrap_database, check_pool_health, connect_lazy_pool, connect_options, connect_pool,
    connect_pool_with_retry, ensure_database_exists, ensure_database_exists_with_retry, ping_pool,
    pool_options, run_migrations, run_migrations_with_timeouts,
    try_acquire_advisory_transaction_lock,
};

#[cfg(test)]
use runtime::POSTGRES_HEALTH_ERROR;

#[cfg(test)]
mod tests;