athena_rs 3.26.1

Hyper performant polyglot Database driver
Documentation
//! Final report-output projection from staged components for `/debug/schema`.
//!
//! This module maps staged diagnostics components into final report output
//! assembly inputs while staged projection payload assembly is delegated to
//! `debug_report_output_from_components_stage_input_assembly`,
//! typed stage-input contracts are delegated to
//! `debug_report_output_from_components_stage_input_contracts`,
//! staged projection payload assembly is delegated to
//! `debug_report_output_from_components_stage_output_assembly`; final output
//! handoff is delegated to the stable facade in
//! `debug_report_output_from_components_from_stage_output_assembly`, which
//! delegates to `debug_report_output_from_components_stage_output_handoff_assembly`,
//! which delegates contract projection to
//! `debug_report_output_from_components_stage_output_contract_handoff_assembly`.
//! Top-level input payload contracts are defined in
//! `debug_report_output_from_components_input_contracts`.

use super::debug_contracts::LoggingSchemaDebugReport;
use super::debug_report_output_from_components_from_stage_output_assembly::build_debug_report_output_from_components_from_stage_output_assembly;
use super::debug_report_output_from_components_input_contracts::LoggingSchemaDebugReportOutputFromComponentsInput;
use super::debug_report_output_from_components_stage_input_assembly::build_debug_report_output_from_components_stage_input_assembly;
use super::debug_report_output_from_components_stage_output_assembly::build_debug_report_output_from_components_stage_output_assembly;

/// Builds final report output from one typed diagnostics-component input payload.
pub(super) fn build_logging_schema_debug_report_from_components_output_from_input(
    input: LoggingSchemaDebugReportOutputFromComponentsInput,
) -> LoggingSchemaDebugReport {
    let LoggingSchemaDebugReportOutputFromComponentsInput {
        logging_client,
        components,
    } = input;

    let stage_input = build_debug_report_output_from_components_stage_input_assembly(
        logging_client.as_str(),
        components,
    );
    let stage = build_debug_report_output_from_components_stage_output_assembly(stage_input);
    build_debug_report_output_from_components_from_stage_output_assembly(stage)
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::api::schema::debug_report_output_from_components_stage_test_fixtures::build_report_output_from_components_input_healthy_empty_for_tests;

    #[test]
    /// Preserves logging-client and staged component fields in final report output.
    fn report_from_components_preserves_logging_client_and_components() {
        let report = build_logging_schema_debug_report_from_components_output_from_input(
            build_report_output_from_components_input_healthy_empty_for_tests(),
        );

        assert_eq!(report.logging_client, "athena_logging");
        assert_eq!(report.summary.health, "healthy");
        assert!(report.expected_tables.is_empty());
        assert!(report.observed_tables.is_empty());
    }
}