athena_rs 3.23.0

Hyper performant polyglot Database driver
Documentation
//! Logging-schema snapshot query helpers for `/debug/schema`.
//!
//! This module orchestrates relation and column snapshot query helpers while
//! concrete fetch execution lives in dedicated modules and row-contract
//! stage assembly is delegated to `debug_snapshot_queries_stage_output_assembly`
//! and final stage-output handoff is delegated to the stable facade in
//! `debug_snapshot_queries_from_stage_output_assembly`, which delegates to
//! `debug_snapshot_queries_stage_output_handoff_assembly`.

use sqlx::postgres::PgPool;

use super::debug_snapshot_contracts::LoggingSchemaSnapshotRows;
use super::debug_snapshot_error::LoggingSchemaSnapshotError;
use super::debug_snapshot_queries_from_stage_output_assembly::build_logging_schema_snapshot_rows_result_from_stage_output_assembly;
use super::debug_snapshot_queries_stage_input_assembly::build_debug_snapshot_queries_stage_input_assembly;
use super::debug_snapshot_queries_stage_input_contracts::LoggingSchemaSnapshotRowsStageInput;
use super::debug_snapshot_queries_stage_output_assembly::build_debug_snapshot_queries_stage_output_assembly;
use super::debug_snapshot_query_columns::fetch_logging_schema_snapshot_columns;
use super::debug_snapshot_query_relations::fetch_logging_schema_snapshot_relations;

/// Fetches all non-system relation and column rows for logging schema diagnostics.
pub(super) async fn fetch_logging_schema_snapshot_rows(
    pool: &PgPool,
) -> Result<LoggingSchemaSnapshotRows, LoggingSchemaSnapshotError> {
    let stage_input: LoggingSchemaSnapshotRowsStageInput =
        build_debug_snapshot_queries_stage_input_assembly(
            fetch_logging_schema_snapshot_relations(pool).await,
            fetch_logging_schema_snapshot_columns(pool).await,
        );
    let stage = build_debug_snapshot_queries_stage_output_assembly(stage_input);

    build_logging_schema_snapshot_rows_result_from_stage_output_assembly(stage)
}