athena_rs 3.26.1

Hyper performant polyglot Database driver
Documentation
//! Logging-schema snapshot fetching for `/debug/schema`.
//!
//! This module owns snapshot orchestration while delegating raw catalog query
//! execution to `debug_snapshot_queries`. Snapshot contracts are shared from
//! `debug_snapshot_contracts` while staged stage-input assembly is delegated to
//! `debug_snapshot_stage_input_assembly`, staged payload assembly is delegated
//! to `debug_snapshot_stage_output_assembly` and final stage-output handoff is
//! delegated to the stable facade in
//! `debug_snapshot_from_stage_output_assembly`, which delegates to
//! `debug_snapshot_stage_output_handoff_assembly`.

use sqlx::postgres::PgPool;

use super::debug_snapshot_contracts::LoggingSchemaSnapshot;
use super::debug_snapshot_error::LoggingSchemaSnapshotError;
use super::debug_snapshot_from_stage_output_assembly::build_logging_schema_snapshot_result_from_stage_output_assembly;
use super::debug_snapshot_queries::fetch_logging_schema_snapshot_rows;
use super::debug_snapshot_stage_input_assembly::build_debug_snapshot_stage_input_assembly;
use super::debug_snapshot_stage_output_assembly::build_debug_snapshot_stage_output_assembly;

/// Fetches all non-system relations and columns for logging schema diagnostics.
pub(super) async fn fetch_logging_schema_snapshot(
    pool: &PgPool,
) -> Result<LoggingSchemaSnapshot, LoggingSchemaSnapshotError> {
    let stage_input =
        build_debug_snapshot_stage_input_assembly(fetch_logging_schema_snapshot_rows(pool).await);
    let stage = build_debug_snapshot_stage_output_assembly(stage_input);
    build_logging_schema_snapshot_result_from_stage_output_assembly(stage)
}