athena_rs 1.1.0

Database gateway API
Documentation
//! Athena
//!
//! A lightweight Database Gateway that proxies and executes queries across multiple backends
//! (Athena/ScyllaDB, PostgreSQL, and Supabase) with simple caching and routing.
//!
//! - Provides REST endpoints for executing SQL against supported drivers
//! - Proxies arbitrary requests while handling auth headers and basic response shaping
//! - Exposes a small set of utilities for driver execution and routing

// re-exports intentionally minimal in lib
use api::pipelines::PipelineDefinition;
use moka::future::Cache;
use reqwest::Client;
use serde_json::Value;
use std::collections::HashMap;

use crate::drivers::postgresql::sqlx_driver::PostgresClientRegistry;
use sqlx::postgres::PgPool;
use std::sync::Arc;

/// REST API surface, endpoints and request handlers.
pub mod api;
/// Athena client SDK with unified query helpers.
pub mod client;
/// Utils for configuration
pub mod config;
pub mod daemon;
/// Data access helpers and Supabase clients used by endpoints.
pub mod data;
/// Database driver integrations (Scylla/Athena, PostgreSQL, Supabase).
pub mod drivers;
/// Error processing and sanitization utilities.
pub mod error;
/// Parsers and helpers related to SQL processing.
pub mod parser;
/// Reverse proxy that forwards requests to the configured target services.
pub mod proxy_request;

pub mod bootstrap;
pub mod cli;

/// HTTP routing helpers and target URL determination.
pub mod router;
pub mod wss;

#[cfg(feature = "cdc")]
pub mod cdc;

/// Shared Actix application state.
pub struct AppState {
    /// Short‑lived response cache for JSON payloads.
    pub cache: Arc<Cache<String, Value>>,
    /// Non‑expiring cache for values that should persist across requests.
    pub immortal_cache: Arc<Cache<String, Value>>,
    /// Shared Reqwest client used by the proxy and endpoints.
    pub client: Client,
    /// Registry of Postgres connections keyed by logical client name.
    pub pg_registry: Arc<PostgresClientRegistry>,
    /// Cache of Postgres pools created from X-JDBC-URL for direct connections.
    pub jdbc_pool_cache: Arc<moka::future::Cache<String, PgPool>>,
    /// When true, gateway fetch routes force camelCase column names to snake_case.
    pub gateway_force_camel_case_to_snake_case: bool,
    /// Optional registry of prebuilt pipeline definitions by name.
    pub pipeline_registry: Option<Arc<HashMap<String, PipelineDefinition>>>,
    /// Optional Postgres client (by name) that receives gateway logs.
    pub logging_client_name: Option<String>,
    /// Optional Postgres client (by name) that stores API keys and auth configuration.
    pub gateway_auth_client_name: Option<String>,
    /// Flag that enables the Prometheus exporter route when true.
    pub prometheus_metrics_enabled: bool,
}

/// Wrapper for the non‑expiring cache used by some endpoints.
pub struct ImmortalCache {
    /// Non‑expiring cache instance.
    pub cache: Arc<Cache<String, Value>>,
}

/// Miscellaneous utilities (logging, helpers).
pub mod utils;

pub use client::AthenaClient;
pub use client::backend::BackendType;
pub use client::builder::AthenaClientBuilder;